public class OkHttpRequestor extends HttpRequestor
HttpRequestor implementation that uses OkHttp
v2. You can only use this if your project includes the OkHttp v2 library.
To use OkHttp v3, see OkHttp3Requestor.
| Modifier and Type | Class and Description |
|---|---|
static class |
OkHttpRequestor.AsyncCallback |
HttpRequestor.Header, HttpRequestor.Response, HttpRequestor.UploaderDEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS| Constructor and Description |
|---|
OkHttpRequestor(com.squareup.okhttp.OkHttpClient client)
Creates a new instance of this requestor that uses
client for its requests. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configureRequest(com.squareup.okhttp.Request.Builder request)
Called beforing building the request and executing it.
|
static com.squareup.okhttp.OkHttpClient |
defaultOkHttpClient()
Returns an
OkHttpClient instance with the default settings for this SDK. |
HttpRequestor.Response |
doGet(java.lang.String url,
java.lang.Iterable<HttpRequestor.Header> headers) |
com.squareup.okhttp.OkHttpClient |
getClient()
Returns a clone of the underlying
OkHttpClient used to make requests. |
protected com.squareup.okhttp.Response |
interceptResponse(com.squareup.okhttp.Response response)
Called before returning
Response from a request. |
HttpRequestor.Uploader |
startPost(java.lang.String url,
java.lang.Iterable<HttpRequestor.Header> headers) |
HttpRequestor.Uploader |
startPut(java.lang.String url,
java.lang.Iterable<HttpRequestor.Header> headers) |
startPostInStreamingModepublic OkHttpRequestor(com.squareup.okhttp.OkHttpClient client)
client for its requests.
The client will be cloned to prevent further modification.
OkHttpClient client = OkHttpRequestor.defaultOkHttpClient(); // Make modifications, if necessary client.setReadTimeout(2, TimeUnit.MINUTES); ... HttpRequestor requestor = new OkHttpRequestor(client);
If you don't use defaultOkHttpClient(), make sure to use Dropbox's
hardened SSL settings from SSLConfig:
client.setSslSocketFactory(SSLConfig.getSSLSocketFactory())
public static com.squareup.okhttp.OkHttpClient defaultOkHttpClient()
OkHttpClient instance with the default settings for this SDK.public com.squareup.okhttp.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.protected void configureRequest(com.squareup.okhttp.Request.Builder request)
This method should be used by subclasses to make any changes or additions to the request before it is issued.
request - Builder of request to be executedprotected com.squareup.okhttp.Response interceptResponse(com.squareup.okhttp.Response response)
Response from a request.
This method should be used by subclasses to add any logging, analytics, or cleanup necessary.
If the response body is consumed, it should be replaced.
response - OkHttp responsepublic HttpRequestor.Response doGet(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException
doGet in class HttpRequestorjava.io.IOExceptionpublic HttpRequestor.Uploader startPost(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException
startPost in class HttpRequestorjava.io.IOExceptionpublic HttpRequestor.Uploader startPut(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException
startPut in class HttpRequestorjava.io.IOException