org.apache.commons.httpclient.methods
Class HeadMethod

java.lang.Object
  |
  +--org.apache.commons.httpclient.HttpMethodBase
        |
        +--org.apache.commons.httpclient.methods.HeadMethod
Direct Known Subclasses:
UrlHeadMethod

public class HeadMethod
extends HttpMethodBase

Implements the HTTP HEAD method.

The HTTP HEAD method is defined in section 9.4 of RFC2616:

The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

Since:
1.0
Version:
$Revision: 1.19.2.2 $
Author:
Remy Maucherat, Mike Bowler, Jeff Dever, oleg Kalnichevski

Fields inherited from class org.apache.commons.httpclient.HttpMethodBase
USER_AGENT
 
Constructor Summary
HeadMethod()
          No-arg constructor.
HeadMethod(java.lang.String uri)
          Constructor specifying a URI.
 
Method Summary
 int getBodyCheckTimeout()
          Return non-compliant response body check timeout.
 java.lang.String getName()
          Returns "HEAD".
protected  void readResponseBody(HttpState state, HttpConnection conn)
          Overrides HttpMethodBase method to not read a response body, despite the presence of a Content-Length or Transfer-Encoding header.
 void recycle()
          Recycles the HTTP method so that it can be used again.
 void setBodyCheckTimeout(int timeout)
          Set non-compliant response body check timeout.
 
Methods inherited from class org.apache.commons.httpclient.HttpMethodBase
addAuthorizationRequestHeader, addContentLengthRequestHeader, addCookieRequestHeader, addHostRequestHeader, addProxyAuthorizationRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, fakeResponse, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getFollowRedirects, getHostConfiguration, getMethodRetryHandler, getPath, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestContentLength, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isConnectionCloseForced, isHttp11, isStrictMode, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, shouldCloseConnection, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeadMethod

public HeadMethod()
No-arg constructor.
Since:
1.0

HeadMethod

public HeadMethod(java.lang.String uri)
Constructor specifying a URI.
Parameters:
uri - either an absolute or relative URI
Since:
1.0
Method Detail

getName

public java.lang.String getName()
Returns "HEAD".
Overrides:
getName in class HttpMethodBase
Returns:
"HEAD"
Since:
2.0

recycle

public void recycle()
Recycles the HTTP method so that it can be used again. Note that all of the instance variables will be reset once this method has been called. This method will also release the connection being used by this HTTP method.
Overrides:
recycle in class HttpMethodBase
Since:
1.0
See Also:
HttpMethodBase.releaseConnection()

readResponseBody

protected void readResponseBody(HttpState state,
                                HttpConnection conn)
                         throws java.io.IOException
Overrides HttpMethodBase method to not read a response body, despite the presence of a Content-Length or Transfer-Encoding header.
Overrides:
readResponseBody in class HttpMethodBase
Parameters:
state - the state information associated with this method
conn - the connection used to execute this HTTP method
Throws:
java.io.IOException - if an I/O (transport) error occurs
HttpException - if a protocol exception occurs.
HttpRecoverableException - if a recoverable transport error occurs. Usually this kind of exceptions can be recovered from by retrying the HTTP method
Since:
2.0
See Also:
HttpMethodBase.readResponse(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection), HttpMethodBase.processResponseBody(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)

getBodyCheckTimeout

public int getBodyCheckTimeout()
Return non-compliant response body check timeout.
Returns:
The period of time in milliseconds to wait for a response body from a non-compliant server. -1 returned when non-compliant response body check is disabled

setBodyCheckTimeout

public void setBodyCheckTimeout(int timeout)
Set non-compliant response body check timeout.
Parameters:
timeout - The period of time in milliseconds to wait for a response body from a non-compliant server. -1 can be used to disable non-compliant response body check


Copyright © 2001-2004 Apache Software Foundation. All Rights Reserved.