public class OkHttp3Requestor extends HttpRequestor
HttpRequestor implementation that uses OkHttp
v3. You can only use this if your project includes the OkHttp v3 library.
To use this, pass INSTANCE to the DbxRequestConfig constructor.
HttpRequestor.Header, HttpRequestor.Response, HttpRequestor.Uploader| Modifier and Type | Field and Description |
|---|---|
static OkHttp3Requestor |
INSTANCE
A thread-safe instance of
OkHttp3Requestor that connects directly
(as opposed to using a proxy). |
DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS| Constructor and Description |
|---|
OkHttp3Requestor(okhttp3.OkHttpClient client)
Creates a new instance of this requestor that uses
client for its requests. |
| Modifier and Type | Method and Description |
|---|---|
HttpRequestor.Response |
doGet(String url,
Iterable<HttpRequestor.Header> headers) |
okhttp3.OkHttpClient |
getClient()
Returns the underlying
OkHttpClient used to make requests. |
HttpRequestor.Uploader |
startPost(String url,
Iterable<HttpRequestor.Header> headers) |
HttpRequestor.Uploader |
startPut(String url,
Iterable<HttpRequestor.Header> headers) |
public static final OkHttp3Requestor INSTANCE
OkHttp3Requestor that connects directly
(as opposed to using a proxy).public OkHttp3Requestor(okhttp3.OkHttpClient client)
client for its requests.
NOTE: This constructor will not enable certificate pinning on the client. If you want
certificate pinning, use the default instance, INSTANCE, or clone the default client
and modify it accordingly:
OkHttpClient client = OkHttpRequestor.INSTANCE.getClient()
.readTimeout(2, TimeUnit.MINUTES)
// ... other modifications
.build();
HttpRequestor requestor = new OkHttpRequestor(client);
client - OkHttpClient to use for requests, never nullpublic okhttp3.OkHttpClient getClient()
OkHttpClient used to make requests.
If you want to modify the client for a particular request, create a new instance of this
requestor with the modified client.OkHttpClient used by this requestor.public HttpRequestor.Response doGet(String url, Iterable<HttpRequestor.Header> headers) throws IOException
doGet in class HttpRequestorIOExceptionpublic HttpRequestor.Uploader startPost(String url, Iterable<HttpRequestor.Header> headers) throws IOException
startPost in class HttpRequestorIOExceptionpublic HttpRequestor.Uploader startPut(String url, Iterable<HttpRequestor.Header> headers) throws IOException
startPut in class HttpRequestorIOException