com.gargoylesoftware.htmlunit
Class HttpWebConnection

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.WebConnectionImpl
      extended by com.gargoylesoftware.htmlunit.HttpWebConnection
All Implemented Interfaces:
WebConnection

public class HttpWebConnection
extends WebConnectionImpl

INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
An object that handles the actual communication portion of page retrieval/submission

Version:
$Revision: 2168 $
Author:
Mike Bowler, Noboru Sinohara, David D. Kilzer, Marc Guillemot, Brad Clarke, Ahmed Ashour

Constructor Summary
HttpWebConnection(WebClient webClient)
          Create a new HTTP web connection instance.
 
Method Summary
protected  HttpClient createHttpClient()
          Creates the httpClient that will be used by this WebConnection.
protected  HttpClient getHttpClient()
          Lazily initialize the httpClient
protected  Log getLog()
          Return the log object for this class
 WebResponse getResponse(WebRequestSettings webRequestSettings)
          Submit a request and retrieve a response
 HttpState getState()
          Return the HttpState that is being used.
protected  int getTimeout()
          Return the timeout to use for socket and connection timeouts for HttpConnectionManager.
 String getVirtualHost()
          Get the virtual host
protected  WebResponseData newWebResponseDataInstance(String statusMessage, List headers, int statusCode, HttpMethodBase method)
          Construct an appropriate WebResponseData.
protected  WebResponse newWebResponseInstance(String charset, WebResponseData responseData, long loadTime, SubmitMethod requestMethod, URL originatingURL)
          Construct an appropriate WebResponse.
protected  void onResponseGenerated(HttpMethodBase httpMethod)
          Called when the response has been generated.
 void setVirtualHost(String virtualHost)
          set the virtual host
 
Methods inherited from class com.gargoylesoftware.htmlunit.WebConnectionImpl
getWebClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpWebConnection

public HttpWebConnection(WebClient webClient)
Create a new HTTP web connection instance.

Parameters:
webClient - The WebClient that is using this connection
Method Detail

getResponse

public WebResponse getResponse(WebRequestSettings webRequestSettings)
                        throws IOException
Submit a request and retrieve a response

Specified by:
getResponse in interface WebConnection
Specified by:
getResponse in class WebConnectionImpl
Parameters:
webRequestSettings - Settings to make the request with
Returns:
See above
Throws:
IOException - If an IO error occurs

onResponseGenerated

protected void onResponseGenerated(HttpMethodBase httpMethod)
Called when the response has been generated. Default action is to release the HttpMethod's connection. Subclasses may override.

Parameters:
httpMethod - the httpMethod used.

getHttpClient

protected HttpClient getHttpClient()
Lazily initialize the httpClient

Returns:
the initialized client

getTimeout

protected int getTimeout()
Return the timeout to use for socket and connection timeouts for HttpConnectionManager. is overridden to 0 by StreamingWebConnection which keeps reading after a timeout and must have long running connections explicitly terminated.

Returns:
the WebClient's timeout.

createHttpClient

protected HttpClient createHttpClient()
Creates the httpClient that will be used by this WebConnection. Extensions may override this method to create the HttpClient with for instance a custom HttpConnectionManager to perform some tracking (see feature request 1438216).

Returns:
the client

getLog

protected final Log getLog()
Return the log object for this class

Returns:
The log object

setVirtualHost

public void setVirtualHost(String virtualHost)
set the virtual host

Parameters:
virtualHost - The virtualHost to set.

getVirtualHost

public String getVirtualHost()
Get the virtual host

Returns:
virtualHost The current virtualHost

getState

public HttpState getState()
Return the HttpState that is being used.

Specified by:
getState in interface WebConnection
Specified by:
getState in class WebConnectionImpl
Returns:
The state.

newWebResponseDataInstance

protected WebResponseData newWebResponseDataInstance(String statusMessage,
                                                     List headers,
                                                     int statusCode,
                                                     HttpMethodBase method)
                                              throws IOException
Construct an appropriate WebResponseData. May be overridden by subclasses to return a specialized WebResponseData.

Parameters:
statusMessage - StatusMessage from the response
headers - response headers
statusCode - response status code
method - request method
Returns:
The WebResponseData to use for this response.
Throws:
IOException - if there is a problem reading the response body.

newWebResponseInstance

protected WebResponse newWebResponseInstance(String charset,
                                             WebResponseData responseData,
                                             long loadTime,
                                             SubmitMethod requestMethod,
                                             URL originatingURL)
Construct an appropriate WebResponse. May be overridden by subclasses to return a specialized WebResponse.

Parameters:
responseData - Data that was send back
charset - Charset used if not returned in the response.
originatingURL - Where this response came from
requestMethod - The method used to get this response
loadTime - How long the response took to be sent
Returns:
the new WebResponse.


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.