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 void
close()
protected okhttp3.OkHttpClient.Builder
newClientBuilder(long connectTimeout, long readTimeout, long writeTimeout)
Response
roundTrip(Request request)
Performs an HTTP request using the given request object.EventStream
stream(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:Transport
Performs 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:
roundTrip
in 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: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 theTransport.roundTrip(Request)
method.- Specified by:
stream
in interfaceTransport
- 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 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").
-
-