|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.httpclient.HttpMethodBase org.apache.commons.httpclient.methods.GetMethod org.archive.httpclient.HttpRecorderGetMethod
public class HttpRecorderGetMethod
Override of GetMethod that marks the passed HttpRecorder w/ the transition from HTTP head to body and that forces a close on the http connection. The actions done in this subclass used to be done by copying org.apache.commons.HttpMethodBase, overlaying our version in place of the one that came w/ httpclient. Here is the patch of the difference between shipped httpclient code and our mods:
-- -1338,6 +1346,12 -- public void releaseConnection() { + // HERITRIX always ants the streams closed. + if (responseConnection != null) + { + responseConnection.close(); + } + if (responseStream != null) { try { // FYI - this may indirectly invoke responseBodyConsumed. -- -1959,6 +1973,11 -- this.statusLine = null; } } + // HERITRIX mark transition from header to content. + if (this.httpRecorder != null) + { + this.httpRecorder.markContentBegin(); + } readResponseBody(state, conn); processResponseBody(state, conn); } catch (IOException e) {
We're not supposed to have access to the underlying connection object; am only violating contract because see cases where httpclient is skipping out w/o cleaning up after itself.
Field Summary | |
---|---|
protected HttpRecorderMethod |
httpRecorderMethod
Instance of http recorder method. |
protected static java.util.logging.Logger |
logger
|
Constructor Summary | |
---|---|
HttpRecorderGetMethod(java.lang.String uri,
HttpRecorder recorder)
|
Method Summary | |
---|---|
protected void |
addProxyConnectionHeader(org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection conn)
Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server. |
int |
execute(org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection conn)
Executes this method using the specified HttpConnection and
HttpState . |
protected void |
readResponseBody(org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection connection)
Read the response body from the given HttpConnection . |
protected boolean |
shouldCloseConnection(org.apache.commons.httpclient.HttpConnection conn)
Tests if the connection should be closed after the method has been executed. |
Methods inherited from class org.apache.commons.httpclient.methods.GetMethod |
---|
getName, recycle |
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase |
---|
abort, addCookieRequestHeader, addHostRequestHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.logging.Logger logger
protected HttpRecorderMethod httpRecorderMethod
Constructor Detail |
---|
public HttpRecorderGetMethod(java.lang.String uri, HttpRecorder recorder)
Method Detail |
---|
protected void readResponseBody(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection connection) throws java.io.IOException, org.apache.commons.httpclient.HttpException
org.apache.commons.httpclient.HttpMethodBase
HttpConnection
.
The current implementation wraps the socket level stream with an appropriate stream for the type of response (chunked, content-length, or auto-close). If there is no response body, the connection associated with the request will be returned to the connection manager.
Subclasses may want to override this method to to customize the processing.
readResponseBody
in class org.apache.commons.httpclient.HttpMethodBase
state
- the state
information associated with this methodconnection
- the connection
used to execute
this HTTP method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.HttpMethodBase.readResponse(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
,
HttpMethodBase.processResponseBody(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected boolean shouldCloseConnection(org.apache.commons.httpclient.HttpConnection conn)
org.apache.commons.httpclient.HttpMethodBase
shouldCloseConnection
in class org.apache.commons.httpclient.HttpMethodBase
conn
- the connection in question
public int execute(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws org.apache.commons.httpclient.HttpException, java.io.IOException
org.apache.commons.httpclient.HttpMethodBase
HttpConnection
and
HttpState
.
execute
in interface org.apache.commons.httpclient.HttpMethod
execute
in class org.apache.commons.httpclient.HttpMethodBase
state
- state
information to associate with this
request. Must be non-null.conn
- the connection
to used to execute
this HTTP method. Must be non-null.
HttpException
- if a protocol exception occurs.
java.io.IOException
- if an I/O (transport) error occursprotected void addProxyConnectionHeader(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws java.io.IOException, org.apache.commons.httpclient.HttpException
org.apache.commons.httpclient.HttpMethodBase
addProxyConnectionHeader
in class org.apache.commons.httpclient.HttpMethodBase
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP method
java.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.
HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |