Class StandardHttpRequestor
HttpRequestor implementation that uses Java's standard library
HttpsURLConnection. If you just want a connection with the
default settings, use the predefined INSTANCE.
If you want to customize the way the connection is configured, create a
subclass that overrides configureConnection(javax.net.ssl.HttpsURLConnection).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfiguration forStandardHttpRequestorthat determines how network connections to the server are established.Nested classes/interfaces inherited from class com.dropbox.core.http.HttpRequestor
HttpRequestor.Header, HttpRequestor.Response -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StandardHttpRequestorA thread-safe instance ofStandardHttpRequestorthat connects directly (as opposed to using a proxy).Fields inherited from class com.dropbox.core.http.HttpRequestor
DEFAULT_CONNECT_TIMEOUT_MILLIS, DEFAULT_READ_TIMEOUT_MILLIS -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance that connects through the given proxy. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigure(HttpURLConnection conn) Can be overriden to configure the underlyingHttpURLConnectionused to make network requests using https.protected voidDeprecated.doGet(String url, Iterable<HttpRequestor.Header> headers) protected voidCalled before returningHttpRequestor.Responsefrom a request.protected HttpURLConnectionprepRequest(String url, Iterable<HttpRequestor.Header> headers, boolean streaming) com.dropbox.core.http.StandardHttpRequestor.UploaderstartPost(String url, Iterable<HttpRequestor.Header> headers) com.dropbox.core.http.StandardHttpRequestor.UploaderstartPostInStreamingMode(String url, Iterable<HttpRequestor.Header> headers) com.dropbox.core.http.StandardHttpRequestor.UploaderstartPut(String url, Iterable<HttpRequestor.Header> headers)
-
Field Details
-
INSTANCE
A thread-safe instance ofStandardHttpRequestorthat connects directly (as opposed to using a proxy).
-
-
Constructor Details
-
StandardHttpRequestor
Creates an instance that connects through the given proxy.
-
-
Method Details
-
doGet
public HttpRequestor.Response doGet(String url, Iterable<HttpRequestor.Header> headers) throws IOException - Specified by:
doGetin classHttpRequestor- Throws:
IOException
-
startPost
public com.dropbox.core.http.StandardHttpRequestor.Uploader startPost(String url, Iterable<HttpRequestor.Header> headers) throws IOException - Specified by:
startPostin classHttpRequestor- Throws:
IOException
-
startPostInStreamingMode
public com.dropbox.core.http.StandardHttpRequestor.Uploader startPostInStreamingMode(String url, Iterable<HttpRequestor.Header> headers) throws IOException - Overrides:
startPostInStreamingModein classHttpRequestor- Throws:
IOException
-
startPut
public com.dropbox.core.http.StandardHttpRequestor.Uploader startPut(String url, Iterable<HttpRequestor.Header> headers) throws IOException - Specified by:
startPutin classHttpRequestor- Throws:
IOException
-
configureConnection
Deprecated.useconfigure(java.net.HttpURLConnection)instead.Can be overridden to configure the underlyingHttpsURLConnectionused to make network requests. If you override this method, you should probably callsuper.configureConnection(conn)in your overridden method.- Throws:
IOException
-
configure
Can be overriden to configure the underlyingHttpURLConnectionused to make network requests using https. Typically the connection will be aHttpsURLConnection, but that is dependent on the Java runtime. Care should be taken when casting the connection (check your JRE).If you are using Google App Engine, configure your
DbxRequestConfigto useGoogleAppEngineRequestoras its defaultHttpRequestor. If you useStandardHttpRequestorin Google App Engine, SSL certificates may not be validated and your app will susceptible to Man-in-the-Middle attacks.- Parameters:
conn- URL connection object returned after creating an https network request.- Throws:
IOException
-
interceptResponse
Called before returningHttpRequestor.Responsefrom a request.This method should be used by subclasses to add any logging, analytics, or cleanup necessary. Note that the connection response code and response streams will already be fetched before calling this method. This means any
IOExceptionfrom reading the response should already have occurred before this method is called.Do not consume the response or error streams in this method.
- Parameters:
conn- HTTP URL connection- Throws:
IOException
-
prepRequest
protected HttpURLConnection prepRequest(String url, Iterable<HttpRequestor.Header> headers, boolean streaming) throws IOException - Throws:
IOException
-
configure(java.net.HttpURLConnection)instead.