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 |
---|---|
protected org.apache.http.impl.client.AbstractHttpClient |
createHttpClient()
Creates the HttpClient that will be used by this WebClient.
|
static DownloadedContent |
downloadContent(InputStream is)
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 org.apache.http.impl.client.AbstractHttpClient |
getHttpClient()
Lazily initializes the internal HTTP client.
|
WebResponse |
getResponse(WebRequest request)
Submits a request and retrieves a response.
|
protected int |
getTimeout()
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 request)
Constructs an appropriate WebResponse.
|
protected void |
onResponseGenerated(org.apache.http.client.methods.HttpUriRequest httpMethod)
Called when the response has been generated.
|
void |
setUseInsecureSSL(boolean useInsecureSSL)
If set to true, the client will accept connections to any host, regardless of
whether they have valid certificates or not.
|
void |
setVirtualHost(String virtualHost)
Sets the virtual host.
|
void |
shutdown()
Shutdown the connection manager.
|
public HttpWebConnection(WebClient webClient)
webClient
- the WebClient that is using this connectionpublic WebResponse getResponse(WebRequest request) throws IOException
getResponse
in interface WebConnection
request
- 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.AbstractHttpClient getHttpClient()
protected int getTimeout()
protected org.apache.http.impl.client.AbstractHttpClient createHttpClient()
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) throws IOException
is
- the stream to readIOException
- in case of read issuesprotected WebResponse newWebResponseInstance(WebResponseData responseData, long loadTime, WebRequest request)
responseData
- Data that was send backrequest
- the request used to get this responseloadTime
- How long the response took to be sentpublic void setUseInsecureSSL(boolean useInsecureSSL) throws GeneralSecurityException
useInsecureSSL
- whether or not to use insecure SSLGeneralSecurityException
- if a security error occurspublic void shutdown()
Copyright © 2002–2013 Gargoyle Software Inc.. All rights reserved.