Class OkHttpRequestor

    • Constructor Detail

      • OkHttpRequestor

        public OkHttpRequestor​(com.squareup.okhttp.OkHttpClient client)
        Creates a new instance of this requestor that uses 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())
         
    • Method Detail

      • defaultOkHttpClient

        public static com.squareup.okhttp.OkHttpClient defaultOkHttpClient()
        Returns an OkHttpClient instance with the default settings for this SDK.
      • getClient

        public com.squareup.okhttp.OkHttpClient getClient()
        Returns a clone of the underlying 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.
        Returns:
        clone of the underlying OkHttpClient used by this requestor.
      • configureRequest

        protected void configureRequest​(com.squareup.okhttp.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
      • interceptResponse

        protected com.squareup.okhttp.Response interceptResponse​(com.squareup.okhttp.Response response)
        Called before returning HttpRequestor.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.

        Parameters:
        response - OkHttp response
        Returns:
        OkHttp response