public class HttpWebConnection extends Object implements WebConnection
WebConnection, using the HttpClient library to perform HTTP requests.| Constructor and Description |
|---|
HttpWebConnection(WebClient webClient)
Creates a new HTTP web connection instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected org.apache.http.impl.client.HttpClientBuilder |
createHttpClientBuilder()
Creates the
HttpClientBuilder that will be used by this WebClient. |
static DownloadedContent |
downloadContent(InputStream is,
int maxInMemory,
File tempFileDirectory)
Reads the content of the stream and saves it in memory or on the file system.
|
protected WebResponse |
downloadResponse(org.apache.http.client.methods.HttpUriRequest httpMethod,
WebRequest webRequest,
org.apache.http.HttpResponse httpResponse,
long startTime)
Downloads the response.
|
protected DownloadedContent |
downloadResponseBody(org.apache.http.HttpResponse httpResponse)
Downloads the response body.
|
protected org.apache.http.impl.client.HttpClientBuilder |
getHttpClientBuilder()
Lazily initializes the internal HTTP client.
|
WebResponse |
getResponse(WebRequest webRequest)
Submits a request and retrieves a response.
|
protected int |
getTimeout(WebRequest webRequest)
Returns the timeout to use for socket and connection timeouts for HttpConnectionManager.
|
String |
getVirtualHost()
Gets the virtual host.
|
protected WebResponse |
makeWebResponse(org.apache.http.HttpResponse httpResponse,
WebRequest webRequest,
DownloadedContent responseBody,
long loadTime)
Converts an HttpMethod into a
WebResponse. |
protected WebResponse |
newWebResponseInstance(WebResponseData responseData,
long loadTime,
WebRequest webRequest)
Constructs an appropriate WebResponse.
|
protected void |
onResponseGenerated(org.apache.http.client.methods.HttpUriRequest httpMethod)
Called when the response has been generated.
|
void |
setVirtualHost(String virtualHost)
Sets the virtual host.
|
public HttpWebConnection(WebClient webClient)
webClient - the WebClient that is using this connectionpublic WebResponse getResponse(WebRequest webRequest) throws IOException
getResponse in interface WebConnectionwebRequest - the requestIOException - if an IO error occursprotected void onResponseGenerated(org.apache.http.client.methods.HttpUriRequest httpMethod)
httpMethod - the httpMethod used (can be null)protected org.apache.http.impl.client.HttpClientBuilder getHttpClientBuilder()
protected int getTimeout(WebRequest webRequest)
webRequest - the request might have his own timeoutprotected org.apache.http.impl.client.HttpClientBuilder createHttpClientBuilder()
HttpClientBuilder that will be used by this WebClient.
Extensions may override this method in order to create a customized
HttpClientBuilder instance (e.g. with a custom
ClientConnectionManager to perform
some tracking; see feature request 1438216).HttpClientBuilder that will be used by this WebConnectionpublic void setVirtualHost(String virtualHost)
virtualHost - the virtualHost to setpublic String getVirtualHost()
protected WebResponse makeWebResponse(org.apache.http.HttpResponse httpResponse, WebRequest webRequest, DownloadedContent responseBody, long loadTime)
WebResponse.httpResponse - the web server's responsewebRequest - the WebRequestresponseBody - the DownloadedContentloadTime - the download timeprotected WebResponse downloadResponse(org.apache.http.client.methods.HttpUriRequest httpMethod, WebRequest webRequest, org.apache.http.HttpResponse httpResponse, long startTime) throws IOException
downloadResponseBody(HttpResponse) and constructs the WebResponse.httpMethod - the HttpUriRequestwebRequest - the WebRequesthttpResponse - the web server's responsestartTime - the download start timeIOException - in case of problem reading/saving the bodyprotected DownloadedContent downloadResponseBody(org.apache.http.HttpResponse httpResponse) throws IOException
httpResponse - the web server's responseIOException - in case of problem reading/saving the bodypublic static DownloadedContent downloadContent(InputStream is, int maxInMemory, File tempFileDirectory) throws IOException
is - the stream to readmaxInMemory - the maximumBytes to store in memory, after which save to a local filetempFileDirectory - the directory to be used or null for the system defaultIOException - in case of read issuesprotected WebResponse newWebResponseInstance(WebResponseData responseData, long loadTime, WebRequest webRequest)
responseData - Data that was sent backwebRequest - the request used to get this responseloadTime - How long the response took to be sentpublic void close()
close in interface AutoCloseableclose in interface WebConnectionCopyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.