Package com.dropbox.core.http
Class OkHttp3Requestor
- java.lang.Object
- 
- com.dropbox.core.http.HttpRequestor
- 
- com.dropbox.core.http.OkHttp3Requestor
 
 
- 
 public class OkHttp3Requestor extends HttpRequestor HttpRequestorimplementation that uses OkHttp v3. You can only use this if your project includes the OkHttp v3 library.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classOkHttp3Requestor.AsyncCallback- 
Nested classes/interfaces inherited from class com.dropbox.core.http.HttpRequestorHttpRequestor.Header, HttpRequestor.Response, HttpRequestor.Uploader
 
- 
 - 
Field Summary- 
Fields inherited from class com.dropbox.core.http.HttpRequestorDEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS
 
- 
 - 
Constructor SummaryConstructors Constructor Description OkHttp3Requestor(okhttp3.OkHttpClient client)Creates a new instance of this requestor that usesclientfor its requests.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconfigureRequest(okhttp3.Request.Builder request)Called beforing building the request and executing it.static okhttp3.OkHttpClientdefaultOkHttpClient()Returns anOkHttpClientinstance with the default settings for this SDK.static okhttp3.OkHttpClient.BuilderdefaultOkHttpClientBuilder()Returns anOkHttpClient.Builderinstance with the default settings for this SDK.HttpRequestor.ResponsedoGet(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers)okhttp3.OkHttpClientgetClient()Returns the underlyingOkHttpClientused to make requests.protected okhttp3.ResponseinterceptResponse(okhttp3.Response response)Called before returningHttpRequestor.Responsefrom a request.HttpRequestor.UploaderstartPost(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers)HttpRequestor.UploaderstartPut(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers)- 
Methods inherited from class com.dropbox.core.http.HttpRequestorstartPostInStreamingMode
 
- 
 
- 
- 
- 
Constructor Detail- 
OkHttp3Requestorpublic OkHttp3Requestor(okhttp3.OkHttpClient client) Creates a new instance of this requestor that usesclientfor its requests.OkHttpClient client = OkHttp3Requestor.defaultOkHttpClient(); HttpRequestor requestor = new OkHttp3Requestor(client); If you need to make modifications to the OkHttpClientsettings:OkHttpClient client = OkHttp3Requestor.defaultOkHttpClientBuilder() .readTimeout(2, TimeUnit.MINUTES) ... .build();If you don't use defaultOkHttpClient()ordefaultOkHttpClientBuilder(), make sure to use Dropbox's hardened SSL settings fromSSLConfig:OkHttpClient client = OkHttpClient.Builder() ... .sslSocketFactory(SSLConfig.getSSLSocketFactory(), SSLConfig.getTrustManager()) .build();
 
- 
 - 
Method Detail- 
defaultOkHttpClientpublic static okhttp3.OkHttpClient defaultOkHttpClient() Returns anOkHttpClientinstance with the default settings for this SDK.
 - 
defaultOkHttpClientBuilderpublic static okhttp3.OkHttpClient.Builder defaultOkHttpClientBuilder() Returns anOkHttpClient.Builderinstance with the default settings for this SDK.
 - 
getClientpublic okhttp3.OkHttpClient getClient() Returns the underlyingOkHttpClientused 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.- Returns:
- underlying OkHttpClientused by this requestor.
 
 - 
configureRequestprotected void configureRequest(okhttp3.Request.Builder request) Called beforing building the request and executing it.This method should be used by subclasses to make any changes or additions to the request before it is issued. - Parameters:
- request- Builder of request to be executed
 
 - 
interceptResponseprotected okhttp3.Response interceptResponse(okhttp3.Response response) Called before returningHttpRequestor.Responsefrom 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. - Parameters:
- response- OkHttp response
- Returns:
- OkHttp response
 
 - 
doGetpublic HttpRequestor.Response doGet(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException - Specified by:
- doGetin class- HttpRequestor
- Throws:
- java.io.IOException
 
 - 
startPostpublic HttpRequestor.Uploader startPost(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException - Specified by:
- startPostin class- HttpRequestor
- Throws:
- java.io.IOException
 
 - 
startPutpublic HttpRequestor.Uploader startPut(java.lang.String url, java.lang.Iterable<HttpRequestor.Header> headers) throws java.io.IOException - Specified by:
- startPutin class- HttpRequestor
- Throws:
- java.io.IOException
 
 
- 
 
-