public class HurlStack extends BaseHttpStack
BaseHttpStack based on HttpURLConnection.| Modifier and Type | Class and Description |
|---|---|
static interface |
HurlStack.UrlRewriter
An interface for transforming URLs before use.
|
| Constructor and Description |
|---|
HurlStack() |
HurlStack(HurlStack.UrlRewriter urlRewriter) |
HurlStack(HurlStack.UrlRewriter urlRewriter,
javax.net.ssl.SSLSocketFactory sslSocketFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected java.net.HttpURLConnection |
createConnection(java.net.URL url)
Create an
HttpURLConnection for the specified url. |
protected java.io.InputStream |
createInputStream(Request<?> request,
java.net.HttpURLConnection connection)
Create and return an InputStream from which the response will be read.
|
protected java.io.OutputStream |
createOutputStream(Request<?> request,
java.net.HttpURLConnection connection,
int length)
Create and return an OutputStream to which the request body will be written.
|
HttpResponse |
executeRequest(Request<?> request,
java.util.Map<java.lang.String,java.lang.String> additionalHeaders)
Performs an HTTP request with the given parameters.
|
performRequestpublic HurlStack()
public HurlStack(HurlStack.UrlRewriter urlRewriter)
urlRewriter - Rewriter to use for request URLspublic HurlStack(HurlStack.UrlRewriter urlRewriter, javax.net.ssl.SSLSocketFactory sslSocketFactory)
urlRewriter - Rewriter to use for request URLssslSocketFactory - SSL factory to use for HTTPS connectionspublic HttpResponse executeRequest(Request<?> request, java.util.Map<java.lang.String,java.lang.String> additionalHeaders) throws java.io.IOException, AuthFailureError
BaseHttpStackA GET request is sent if request.getPostBody() == null. A POST request is sent otherwise, and the Content-Type header is set to request.getPostBodyContentType().
executeRequest in class BaseHttpStackrequest - the request to performadditionalHeaders - additional headers to be sent together with Request.getHeaders()HttpResponsejava.net.SocketTimeoutException - if the request times outjava.io.IOException - if another I/O error occurs during the requestAuthFailureError - if an authentication failure occurs during the requestprotected java.io.InputStream createInputStream(Request<?> request, java.net.HttpURLConnection connection)
May be overridden by subclasses to manipulate or monitor this input stream.
request - current request.connection - current connection of request.protected java.net.HttpURLConnection createConnection(java.net.URL url)
throws java.io.IOException
HttpURLConnection for the specified url.java.io.IOExceptionprotected java.io.OutputStream createOutputStream(Request<?> request, java.net.HttpURLConnection connection, int length) throws java.io.IOException
May be overridden by subclasses to manipulate or monitor this output stream.
request - current request.connection - current connection of request.length - size of stream to write.java.io.IOException - if an I/O error occurs while creating the stream.