Class OkHttpTransport

    • Constructor Detail

      • OkHttpTransport

        public OkHttpTransport()
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface Transport
      • newClientBuilder

        protected okhttp3.OkHttpClient.Builder newClientBuilder​(long connectTimeout,
                                                                long readTimeout,
                                                                long writeTimeout)
      • roundTrip

        public Response roundTrip​(Request request)
                           throws IOException
        Description copied from interface: Transport
        Performs an HTTP request using the given request object. If the request results in a Stitch service error, the caller is responsible for calling StitchError.handleRequestError(Response) to decode the exception, as this method will not throw the service exception.
        Specified by:
        roundTrip in interface Transport
        Parameters:
        request - The HTTP request to perform.
        Returns:
        The response to the request.
        Throws:
        IOException
      • stream

        public EventStream stream​(Request request)
                           throws IOException,
                                  StitchServiceException
        Description copied from interface: Transport
        Opens a Server-Sent Event (SSE) stream. See https://www.w3.org/TR/2009/WD-eventsource-20090421/ for specification details. If the underlying request to the Stitch server results in a service exception, this function will detect it and throw it, unlike the Transport.roundTrip(Request) method.
        Specified by:
        stream in interface Transport
        Parameters:
        request - The request to open the stream.
        Returns:
        A raw EventStream representing the opened change stream.
        Throws:
        IOException - if the request fails to due to an I/O error
        StitchServiceException - if the request to the Stitch server was completed, but the stream could not be opened due to a Stitch error (such as "InvalidSession").