Class OkHttpTransport
- java.lang.Object
-
- com.mongodb.stitch.core.internal.net.OkHttpTransport
-
-
Field Summary
-
Fields inherited from interface com.mongodb.stitch.core.internal.net.Transport
MAX_REQUEST_SIZE
-
-
Constructor Summary
Constructors Constructor Description OkHttpTransport()
-
Method Summary
Modifier and Type Method Description voidclose()protected okhttp3.OkHttpClient.BuildernewClientBuilder(long connectTimeout, long readTimeout, long writeTimeout)ResponseroundTrip(Request request)Performs an HTTP request using the given request object.EventStreamstream(Request request)Opens a Server-Sent Event (SSE) stream.
-
-
-
Method Detail
-
newClientBuilder
protected okhttp3.OkHttpClient.Builder newClientBuilder(long connectTimeout, long readTimeout, long writeTimeout)
-
roundTrip
public Response roundTrip(Request request) throws IOException
Description copied from interface:TransportPerforms an HTTP request using the given request object. If the request results in a Stitch service error, the caller is responsible for callingStitchError.handleRequestError(Response)to decode the exception, as this method will not throw the service exception.- Specified by:
roundTripin interfaceTransport- 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:TransportOpens 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 theTransport.roundTrip(Request)method.- Specified by:
streamin interfaceTransport- Parameters:
request- The request to open the stream.- Returns:
- A raw
EventStreamrepresenting the opened change stream. - Throws:
IOException- if the request fails to due to an I/O errorStitchServiceException- if the request to the Stitch server was completed, but the stream could not be opened due to a Stitch error (such as "InvalidSession").
-
-