public class ApacheHttpClient extends java.lang.Object implements HttpClient
Modifier and Type | Class and Description |
---|---|
static class |
ApacheHttpClient.Factory |
Modifier and Type | Field and Description |
---|---|
private org.apache.http.client.HttpClient |
client |
private static int |
MAX_REDIRECTS |
private org.apache.http.HttpHost |
targetHost |
private java.net.URL |
url |
Constructor and Description |
---|
ApacheHttpClient(org.apache.http.client.HttpClient client,
java.net.URL url) |
Modifier and Type | Method and Description |
---|---|
private java.net.URI |
buildUri(org.apache.http.protocol.HttpContext context,
java.lang.String location) |
void |
close()
Closes the connections associated with this client.
|
protected org.apache.http.protocol.HttpContext |
createContext() |
private static org.apache.http.client.methods.HttpUriRequest |
createHttpUriRequest(HttpMethod method,
java.lang.String url) |
private HttpResponse |
createResponse(org.apache.http.HttpResponse response,
org.apache.http.protocol.HttpContext context) |
HttpResponse |
execute(HttpRequest request,
boolean followRedirects)
Executes the given request.
|
private org.apache.http.HttpResponse |
fallBackExecute(org.apache.http.protocol.HttpContext context,
org.apache.http.client.methods.HttpUriRequest httpMethod) |
private org.apache.http.HttpResponse |
followRedirects(org.apache.http.client.HttpClient client,
org.apache.http.protocol.HttpContext context,
org.apache.http.HttpResponse response,
int redirectCount) |
private boolean |
isRedirect(org.apache.http.HttpResponse response) |
private static final int MAX_REDIRECTS
private final java.net.URL url
private final org.apache.http.HttpHost targetHost
private final org.apache.http.client.HttpClient client
public ApacheHttpClient(org.apache.http.client.HttpClient client, java.net.URL url)
public HttpResponse execute(HttpRequest request, boolean followRedirects) throws java.io.IOException
HttpClient
execute
in interface HttpClient
request
- the request to execute.followRedirects
- whether to automatically follow redirects.java.io.IOException
- if an I/O error occurs.private HttpResponse createResponse(org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws java.io.IOException
java.io.IOException
protected org.apache.http.protocol.HttpContext createContext()
private static org.apache.http.client.methods.HttpUriRequest createHttpUriRequest(HttpMethod method, java.lang.String url)
private org.apache.http.HttpResponse fallBackExecute(org.apache.http.protocol.HttpContext context, org.apache.http.client.methods.HttpUriRequest httpMethod) throws java.io.IOException
java.io.IOException
private org.apache.http.HttpResponse followRedirects(org.apache.http.client.HttpClient client, org.apache.http.protocol.HttpContext context, org.apache.http.HttpResponse response, int redirectCount)
private java.net.URI buildUri(org.apache.http.protocol.HttpContext context, java.lang.String location) throws java.net.URISyntaxException
java.net.URISyntaxException
private boolean isRedirect(org.apache.http.HttpResponse response)
public void close() throws java.io.IOException
HttpClient
close
in interface HttpClient
java.io.IOException
- if an I/O error occurs.