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 HttpClientBuilder |
createHttpClientBuilder()
Creates the HttpClientBuilder that will be used by this WebClient.
|
static DownloadedContent |
downloadContent(InputStream is,
int maxInMemory)
Reads the content of the stream and saves it in memory or on the file system.
|
protected DownloadedContent |
downloadResponseBody(org.apache.http.HttpResponse httpResponse)
Downloads the response body.
|
protected 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 |
newWebResponseInstance(WebResponseData responseData,
long loadTime,
WebRequest webRequest)
Constructs an appropriate WebResponse.
|
protected void |
onResponseGenerated(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 WebConnection
webRequest
- the requestIOException
- if an IO error occursprotected void onResponseGenerated(HttpUriRequest httpMethod)
httpMethod
- the httpMethod used (can be null)protected HttpClientBuilder getHttpClientBuilder()
protected int getTimeout(WebRequest webRequest)
webRequest
- the request might have his own timeoutprotected HttpClientBuilder createHttpClientBuilder()
ClientConnectionManager
to perform
some tracking; see feature request 1438216).public void setVirtualHost(String virtualHost)
virtualHost
- the virtualHost to setpublic String getVirtualHost()
protected 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) throws IOException
is
- the stream to readmaxInMemory
- the maximumBytes to store in memory, after which save to a local fileIOException
- in case of read issuesprotected WebResponse newWebResponseInstance(WebResponseData responseData, long loadTime, WebRequest webRequest)
responseData
- Data that was send backwebRequest
- the request used to get this responseloadTime
- How long the response took to be sentpublic void close()
close
in interface WebConnection
close
in interface AutoCloseable
Copyright © 2002–2022 Gargoyle Software Inc.. All rights reserved.