public class StandardHttpRequestor extends HttpRequestor
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)
.
HttpRequestor.Header, HttpRequestor.Response
Modifier and Type | Field and Description |
---|---|
static int |
DefaultConnectTimeoutMillis
We pass this value to
URLConnection.setConnectTimeout(int) . |
static int |
DefaultReadTimeoutMillis
We pass this value to
URLConnection.setReadTimeout(int) . |
static StandardHttpRequestor |
Instance
A thread-safe instance of
StandardHttpRequestor that connects directly
(as opposed to using a proxy). |
Constructor and Description |
---|
StandardHttpRequestor()
Creates an instance that uses a direct HTTP connection (as opposed to
using a proxy).
|
StandardHttpRequestor(Proxy proxy)
Creates an instance that connects through the given proxy.
|
Modifier and Type | Method and Description |
---|---|
protected void |
configureConnection(HttpsURLConnection conn)
Can be overridden to configure the underlying
HttpsURLConnection used to make
network requests. |
HttpRequestor.Response |
doGet(String url,
Iterable<HttpRequestor.Header> headers) |
com.dropbox.core.http.StandardHttpRequestor.Uploader |
startPost(String url,
Iterable<HttpRequestor.Header> headers) |
com.dropbox.core.http.StandardHttpRequestor.Uploader |
startPut(String url,
Iterable<HttpRequestor.Header> headers) |
public static final int DefaultConnectTimeoutMillis
URLConnection.setConnectTimeout(int)
. You can
change this setting by creating a subclass and overriding
configureConnection(javax.net.ssl.HttpsURLConnection)
.public static final int DefaultReadTimeoutMillis
URLConnection.setReadTimeout(int)
. You can
change this setting by creating a subclass and overriding
configureConnection(javax.net.ssl.HttpsURLConnection)
.public static final StandardHttpRequestor Instance
StandardHttpRequestor
that connects directly
(as opposed to using a proxy).public StandardHttpRequestor()
public StandardHttpRequestor(Proxy proxy)
public HttpRequestor.Response doGet(String url, Iterable<HttpRequestor.Header> headers) throws IOException
doGet
in class HttpRequestor
IOException
public com.dropbox.core.http.StandardHttpRequestor.Uploader startPost(String url, Iterable<HttpRequestor.Header> headers) throws IOException
startPost
in class HttpRequestor
IOException
public com.dropbox.core.http.StandardHttpRequestor.Uploader startPut(String url, Iterable<HttpRequestor.Header> headers) throws IOException
startPut
in class HttpRequestor
IOException
protected void configureConnection(HttpsURLConnection conn) throws IOException
HttpsURLConnection
used to make
network requests. If you override this method, you should probably call
super.configureConnection(conn)
in your overridden method.IOException
Copyright © 2014. All rights reserved.