Java Doc for HttpMethodBase.java in  » Web-Crawler » heritrix » org » apache » commons » httpclient » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Crawler » heritrix » org.apache.commons.httpclient 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.httpclient.HttpMethodBase

HttpMethodBase
abstract public class HttpMethodBase implements HttpMethod(Code)
An abstract base implementation of HttpMethod.

At minimum, subclasses will need to override:

When a method requires additional request headers, subclasses will typically want to override:

When a method expects specific response headers, subclasses may want to override:


author:
   Remy Maucherat
author:
   Rodney Waldhoff
author:
   Sean C. Sullivan
author:
   dIon Gillard
author:
   Jeff Dever
author:
   Davanum Srinivas
author:
   Ortwin Glueck
author:
   Eric Johnson
author:
   Michael Becke
author:
   Oleg Kalnichevski
author:
   Mike Bowler
author:
   Gary Gregory
author:
   Christian Kohlschuetter
version:
   $Revision: 4946 $ $Date: 2007-02-28 23:35:32 +0000 (Wed, 28 Feb 2007) $



Constructor Summary
public  HttpMethodBase()
     No-arg constructor.
public  HttpMethodBase(String uri)
     Constructor specifying a URI. It is responsibility of the caller to ensure that URI elements (path & query parameters) are properly encoded (URL safe).
Parameters:
  uri - either an absolute or relative URI.

Method Summary
public  voidabort()
     Aborts the execution of this method.
protected  voidaddCookieRequestHeader(HttpState state, HttpConnection conn)
     Generates Cookie request headers for those Cookie cookie s that match the given host, port and path.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidaddHostRequestHeader(HttpState state, HttpConnection conn)
     Generates Host request header, as long as no Host request header already exists.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidaddProxyConnectionHeader(HttpState state, HttpConnection conn)
     Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
public  voidaddRequestHeader(Header header)
     Adds the specified request header, NOT overwriting any previous value.
public  voidaddRequestHeader(String headerName, String headerValue)
     Adds the specified request header, NOT overwriting any previous value.
protected  voidaddRequestHeaders(HttpState state, HttpConnection conn)
     Generates all the required request Header header s to be submitted via the given HttpConnection connection .

This implementation adds User-Agent, Host, Cookie, Authorization, Proxy-Authorization and Proxy-Connection headers, when appropriate.

Subclasses may want to override this method to to add additional headers, and may choose to invoke this implementation (via super) to add the "standard" headers.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
public  voidaddResponseFooter(Header footer)
     Use this method internally to add footers.
protected  voidaddUserAgentRequestHeader(HttpState state, HttpConnection conn)
     Generates default User-Agent request header, as long as no User-Agent request header already exists.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidcheckNotUsed()
     Throws an IllegalStateException if the HTTP method has been already HttpMethodBase.execute executed , but not HttpMethodBase.recycle recycled .
protected  voidcheckUsed()
     Throws an IllegalStateException if the HTTP method has not been HttpMethodBase.execute executed since last HttpMethodBase.recycle recycle .
public  intexecute(HttpState state, HttpConnection conn)
     Executes this method using the specified HttpConnection and HttpState.
 voidfakeResponse(StatusLine statusline, HeaderGroup responseheaders, InputStream responseStream)
     This method is a dirty hack intended to work around current (2.0) design flaw that prevents the user from obtaining correct status code, headers and response body from the preceding HTTP CONNECT method.
protected static  StringgenerateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version)
     Generates HTTP request line according to the specified attributes.
Parameters:
  connection - the HttpConnection connection used to executethis HTTP method
Parameters:
  name - the method name generate a request for
Parameters:
  requestPath - the path string for the request
Parameters:
  query - the query string for the request
Parameters:
  version - the protocol version to use (e.g.
public  StringgetAuthenticationRealm()
     Returns authentication realm, if it has been used during authentication process.
protected  StringgetContentCharSet(Header contentheader)
     Returns the character set from the Content-Type header.
Parameters:
  contentheader - The content header.
public  booleangetDoAuthentication()
    
public  HttpVersiongetEffectiveVersion()
    
public  booleangetFollowRedirects()
     Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise.
public  AuthStategetHostAuthState()
    
public  HostConfigurationgetHostConfiguration()
     Returns the HostConfiguration host configuration .
public  MethodRetryHandlergetMethodRetryHandler()
    
abstract public  StringgetName()
     Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST".
public  HttpMethodParamsgetParams()
     Returns HttpMethodParams HTTP protocol parameters associated with this method.
public  StringgetPath()
     Gets the path of this HTTP method.
public  AuthStategetProxyAuthState()
    
public  StringgetProxyAuthenticationRealm()
     Returns proxy authentication realm, if it has been used during authentication process.
public  StringgetQueryString()
     Gets the query string of this HTTP method.
public  intgetRecoverableExceptionCount()
    
public  StringgetRequestCharSet()
     Returns the character encoding of the request from the Content-Type header.
public  HeadergetRequestHeader(String headerName)
     Returns the specified request header.
protected  HeaderGroupgetRequestHeaderGroup()
     Gets the HeaderGroup header group storing the request headers.
public  Header[]getRequestHeaders()
    
public  Header[]getRequestHeaders(String headerName)
    
public  byte[]getResponseBody()
     Returns the response body of the HTTP method, if any, as an array of bytes. If response body is not available or cannot be read, returns null Note: This will cause the entire response body to be buffered in memory.
public  InputStreamgetResponseBodyAsStream()
     Returns the response body of the HTTP method, if any, as an InputStream .
public  StringgetResponseBodyAsString()
     Returns the response body of the HTTP method, if any, as a String .
public  StringgetResponseCharSet()
     Returns the character encoding of the response from the Content-Type header.
public  longgetResponseContentLength()
     Return the length (in bytes) of the response body, as specified in a Content-Length header.

Return -1 when the content-length is unknown.

content length, if Content-Length header is available.
public  HeadergetResponseFooter(String footerName)
     Gets the response footer associated with the given name. Footer name matching is case insensitive. null will be returned if either footerName is null or there is no matching footer for footerName or there are no footers available.
public  Header[]getResponseFooters()
     Returns an array of the response footers that the HTTP method currently has in the order in which they were read.
public  HeadergetResponseHeader(String headerName)
     Gets the response header associated with the given name.
protected  HeaderGroupgetResponseHeaderGroup()
     Gets the HeaderGroup header group storing the response headers.
public  Header[]getResponseHeaders(String headerName)
    
public  Header[]getResponseHeaders()
     Returns an array of the response headers that the HTTP method currently has in the order in which they were read.
protected  InputStreamgetResponseStream()
     Returns a stream from which the body of the current response may be read.
protected  HeaderGroupgetResponseTrailerHeaderGroup()
     Gets the HeaderGroup header group storing the response trailer headers as per RFC 2616 section 3.6.1.
public  intgetStatusCode()
     Returns the response status code.
public  StatusLinegetStatusLine()
     Provides access to the response status line.
public  StringgetStatusText()
     Returns the status text (or "reason phrase") associated with the latest response.
public  URIgetURI()
    
public  booleanhasBeenUsed()
     Returns true if the HTTP method has been already HttpMethodBase.execute executed , but not HttpMethodBase.recycle recycled .
public  booleanisAborted()
    
protected  booleanisConnectionCloseForced()
     Tests if the connection should be force-closed when no longer needed.
public  booleanisHttp11()
     Returns true if version 1.1 of the HTTP protocol should be used per default, false if version 1.0 should be used.
public  booleanisRequestSent()
     Returns true if the HTTP has been transmitted to the target server in its entirety, false otherwise.
public  booleanisStrictMode()
    
protected  voidprocessResponseBody(HttpState state, HttpConnection conn)
     This method is invoked immediately after HttpMethodBase.readResponseBody(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom body processing.
protected  voidprocessResponseHeaders(HttpState state, HttpConnection conn)
     This method is invoked immediately after HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom response headers processing.
protected  voidprocessStatusLine(HttpState state, HttpConnection conn)
     This method is invoked immediately after HttpMethodBase.readStatusLine(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom response status line processing.
protected  voidreadResponse(HttpState state, HttpConnection conn)
     Reads the response from the given HttpConnection connection .

The response is processed as the following sequence of actions:

  1. HttpMethodBase.readStatusLine(HttpState,HttpConnection) is invoked to read the request line.
  2. HttpMethodBase.processStatusLine(HttpState,HttpConnection) is invoked, allowing the method to process the status line if desired.
  3. HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) is invoked to read the associated headers.
  4. HttpMethodBase.processResponseHeaders(HttpState,HttpConnection) is invoked, allowing the method to process the headers if desired.
  5. HttpMethodBase.readResponseBody(HttpState,HttpConnection) is invoked to read the associated body (if any).
  6. HttpMethodBase.processResponseBody(HttpState,HttpConnection) is invoked, allowing the method to process the response body if desired.
Subclasses may want to override one or more of the above methods to to customize the processing.
protected  voidreadResponseBody(HttpState state, HttpConnection conn)
     Read the response body from the given HttpConnection .

The current implementation wraps the socket level stream with an appropriate stream for the type of response (chunked, content-length, or auto-close).

protected  voidreadResponseHeaders(HttpState state, HttpConnection conn)
     Reads the response headers from the given HttpConnection connection .

Subclasses may want to override this method to to customize the processing.

"It must be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma." - HTTP/1.0 (4.3)


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidreadStatusLine(HttpState state, HttpConnection conn)
     Read the status line from the given HttpConnection , setting my HttpMethodBase.getStatusCode status code and HttpMethodBase.getStatusText statustext .

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
public  voidrecycle()
     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.
public  voidreleaseConnection()
     Releases the connection being used by this HTTP method.
public  voidremoveRequestHeader(String headerName)
     Remove the request header associated with the given name.
public  voidremoveRequestHeader(Header header)
     Removes the given request header.
protected  voidresponseBodyConsumed()
     A response has been consumed.
protected  voidsetConnectionCloseForced(boolean b)
     Sets whether or not the connection should be force-closed when no longer needed.
public  voidsetDoAuthentication(boolean doAuthentication)
    
public  voidsetFollowRedirects(boolean followRedirects)
    
public  voidsetHostConfiguration(HostConfiguration hostconfig)
     Sets the HostConfiguration host configuration .
public  voidsetHttp11(boolean http11)
     Sets whether version 1.1 of the HTTP protocol should be used per default.
public  voidsetMethodRetryHandler(MethodRetryHandler handler)
    
public  voidsetParams(HttpMethodParams params)
     Assigns HttpMethodParams HTTP protocol parameters for this method.
public  voidsetPath(String path)
     Sets the path of the HTTP method. It is responsibility of the caller to ensure that the path is properly encoded (URL safe).
Parameters:
  path - the path of the HTTP method.
public  voidsetQueryString(String queryString)
     Sets the query string of this HTTP method.
public  voidsetQueryString(NameValuePair[] params)
     Sets the query string of this HTTP method.
public  voidsetRequestHeader(String headerName, String headerValue)
     Set the specified request header, overwriting any previous value.
public  voidsetRequestHeader(Header header)
     Sets the specified request header, overwriting any previous value.
protected  voidsetResponseStream(InputStream responseStream)
     Sets the response stream.
public  voidsetStrictMode(boolean strictMode)
     Defines how strictly HttpClient follows the HTTP protocol specification (RFC 2616 and other relevant RFCs).
public  voidsetURI(URI uri)
     Sets the URI for this method.
protected  booleanshouldCloseConnection(HttpConnection conn)
     Tests if the connection should be closed after the method has been executed.
public  booleanvalidate()
     Returns true the method is ready to execute, false otherwise.
protected  voidwriteRequest(HttpState state, HttpConnection conn)
    

Sends the request via the given HttpConnection connection .

The request is written as the following sequence of actions:

  1. HttpMethodBase.writeRequestLine(HttpState,HttpConnection) is invoked to write the request line.
  2. HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection) is invoked to write the associated headers.
  3. \r\n is sent to close the head part of the request.
  4. HttpMethodBase.writeRequestBody(HttpState,HttpConnection) is invoked to write the body part of the request.

Subclasses may want to override one or more of the above methods to to customize the processing.

protected  booleanwriteRequestBody(HttpState state, HttpConnection conn)
     Writes the request body to the given HttpConnection connection .

This method should return true if the request body was actually sent (or is empty), or false if it could not be sent for some reason.

This implementation writes nothing and returns true.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method true
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidwriteRequestHeaders(HttpState state, HttpConnection conn)
     Writes the request headers to the given HttpConnection connection .

This implementation invokes HttpMethodBase.addRequestHeaders(HttpState,HttpConnection) , and then writes each header to the request stream.

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.
protected  voidwriteRequestLine(HttpState state, HttpConnection conn)
     Writes the request line to the given HttpConnection connection .

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs.


Constructor Detail
HttpMethodBase
public HttpMethodBase()(Code)
No-arg constructor.



HttpMethodBase
public HttpMethodBase(String uri) throws IllegalArgumentException, IllegalStateException(Code)
Constructor specifying a URI. It is responsibility of the caller to ensure that URI elements (path & query parameters) are properly encoded (URL safe).
Parameters:
  uri - either an absolute or relative URI. The URI is expectedto be URL-encoded
throws:
  IllegalArgumentException - when URI is invalid
throws:
  IllegalStateException - when protocol of the absolute URI is not recognised




Method Detail
abort
public void abort()(Code)
Aborts the execution of this method.
since:
   3.0



addCookieRequestHeader
protected void addCookieRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Generates Cookie request headers for those Cookie cookie s that match the given host, port and path.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



addHostRequestHeader
protected void addHostRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Generates Host request header, as long as no Host request header already exists.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



addProxyConnectionHeader
protected void addProxyConnectionHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



addRequestHeader
public void addRequestHeader(Header header)(Code)
Adds the specified request header, NOT overwriting any previous value. Note that header-name matching is case insensitive.
Parameters:
  header - the header to add to the request



addRequestHeader
public void addRequestHeader(String headerName, String headerValue)(Code)
Adds the specified request header, NOT overwriting any previous value. Note that header-name matching is case insensitive.
Parameters:
  headerName - the header's name
Parameters:
  headerValue - the header's value



addRequestHeaders
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Generates all the required request Header header s to be submitted via the given HttpConnection connection .

This implementation adds User-Agent, Host, Cookie, Authorization, Proxy-Authorization and Proxy-Connection headers, when appropriate.

Subclasses may want to override this method to to add additional headers, and may choose to invoke this implementation (via super) to add the "standard" headers.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   HttpMethodBase.writeRequestHeaders



addResponseFooter
public void addResponseFooter(Header footer)(Code)
Use this method internally to add footers.
Parameters:
  footer - The footer to add.



addUserAgentRequestHeader
protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Generates default User-Agent request header, as long as no User-Agent request header already exists.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



checkNotUsed
protected void checkNotUsed() throws IllegalStateException(Code)
Throws an IllegalStateException if the HTTP method has been already HttpMethodBase.execute executed , but not HttpMethodBase.recycle recycled .
throws:
  IllegalStateException - if the method has been used and notrecycled



checkUsed
protected void checkUsed() throws IllegalStateException(Code)
Throws an IllegalStateException if the HTTP method has not been HttpMethodBase.execute executed since last HttpMethodBase.recycle recycle .
throws:
  IllegalStateException - if not used



execute
public int execute(HttpState state, HttpConnection conn) throws HttpException, IOException(Code)
Executes this method using the specified HttpConnection and HttpState.
Parameters:
  state - HttpState state information to associate with thisrequest. Must be non-null.
Parameters:
  conn - the HttpConnection connection to used to executethis HTTP method. Must be non-null. the integer status code if one was obtained, or -1
throws:
  IOException - if an I/O (transport) error occurs
throws:
  HttpException - if a protocol exception occurs.



fakeResponse
void fakeResponse(StatusLine statusline, HeaderGroup responseheaders, InputStream responseStream)(Code)
This method is a dirty hack intended to work around current (2.0) design flaw that prevents the user from obtaining correct status code, headers and response body from the preceding HTTP CONNECT method. TODO: Remove this crap as soon as possible



generateRequestLine
protected static String generateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version)(Code)
Generates HTTP request line according to the specified attributes.
Parameters:
  connection - the HttpConnection connection used to executethis HTTP method
Parameters:
  name - the method name generate a request for
Parameters:
  requestPath - the path string for the request
Parameters:
  query - the query string for the request
Parameters:
  version - the protocol version to use (e.g. HTTP/1.0) HTTP request line



getAuthenticationRealm
public String getAuthenticationRealm()(Code)
Returns authentication realm, if it has been used during authentication process. Otherwise returns null. authentication realm



getContentCharSet
protected String getContentCharSet(Header contentheader)(Code)
Returns the character set from the Content-Type header.
Parameters:
  contentheader - The content header. String The character set.



getDoAuthentication
public boolean getDoAuthentication()(Code)
Returns true if the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.), false otherwise true if authentication challenges will be processed automatically, false otherwise.
since:
   2.0



getEffectiveVersion
public HttpVersion getEffectiveVersion()(Code)
Returns the HTTP version used with this method (may be null if undefined, that is, the method has not been executed) HTTP version.
since:
   3.0



getFollowRedirects
public boolean getFollowRedirects()(Code)
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise. true if the method will automatically follow HTTP redirects, false otherwise.



getHostAuthState
public AuthState getHostAuthState()(Code)
Returns the target host AuthState authentication state host authentication state
since:
   3.0



getHostConfiguration
public HostConfiguration getHostConfiguration()(Code)
Returns the HostConfiguration host configuration . the host configuration



getMethodRetryHandler
public MethodRetryHandler getMethodRetryHandler()(Code)
Returns the MethodRetryHandler retry handler for this HTTP method the methodRetryHandlerHttpMethodParams



getName
abstract public String getName()(Code)
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST". the name of this method



getParams
public HttpMethodParams getParams()(Code)
Returns HttpMethodParams HTTP protocol parameters associated with this method. HTTP parameters.
since:
   3.0



getPath
public String getPath()(Code)
Gets the path of this HTTP method. Calling this method after the request has been executed will return the actual path, following any redirects automatically handled by this HTTP method. the path to request or "/" if the path is blank.



getProxyAuthState
public AuthState getProxyAuthState()(Code)
Returns the proxy AuthState authentication state host authentication state
since:
   3.0



getProxyAuthenticationRealm
public String getProxyAuthenticationRealm()(Code)
Returns proxy authentication realm, if it has been used during authentication process. Otherwise returns null. proxy authentication realm



getQueryString
public String getQueryString()(Code)
Gets the query string of this HTTP method. The query string



getRecoverableExceptionCount
public int getRecoverableExceptionCount()(Code)
The number of recoverable exceptions handled by the method.



getRequestCharSet
public String getRequestCharSet()(Code)
Returns the character encoding of the request from the Content-Type header. String The character set.



getRequestHeader
public Header getRequestHeader(String headerName)(Code)
Returns the specified request header. Note that header-name matching is case insensitive. null will be returned if either headerName is null or there is no matching header for headerName.
Parameters:
  headerName - The name of the header to be returned. The specified request header.
since:
   3.0



getRequestHeaderGroup
protected HeaderGroup getRequestHeaderGroup()(Code)
Gets the HeaderGroup header group storing the request headers. a HeaderGroup
since:
   2.0beta1



getRequestHeaders
public Header[] getRequestHeaders()(Code)
Returns an array of the requests headers that the HTTP method currently has an array of my request headers.



getRequestHeaders
public Header[] getRequestHeaders(String headerName)(Code)

See Also:   org.apache.commons.httpclient.HttpMethod.getRequestHeaders(java.lang.String)



getResponseBody
public byte[] getResponseBody() throws IOException(Code)
Returns the response body of the HTTP method, if any, as an array of bytes. If response body is not available or cannot be read, returns null Note: This will cause the entire response body to be buffered in memory. A malicious server may easily exhaust all the VM memory. It is strongly recommended, to use getResponseAsStream if the content length of the response is unknown or resonably large. The response body.
throws:
  IOException - If an I/O (transport) problem occurs while obtaining the response body.



getResponseBodyAsStream
public InputStream getResponseBodyAsStream() throws IOException(Code)
Returns the response body of the HTTP method, if any, as an InputStream . If response body is not available, returns null The response body
throws:
  IOException - If an I/O (transport) problem occurs while obtaining the response body.



getResponseBodyAsString
public String getResponseBodyAsString() throws IOException(Code)
Returns the response body of the HTTP method, if any, as a String . If response body is not available or cannot be read, returns null The string conversion on the data is done using the character encoding specified in Content-Type header. Note: This will cause the entire response body to be buffered in memory. A malicious server may easily exhaust all the VM memory. It is strongly recommended, to use getResponseAsStream if the content length of the response is unknown or resonably large. The response body.
throws:
  IOException - If an I/O (transport) problem occurs while obtaining the response body.



getResponseCharSet
public String getResponseCharSet()(Code)
Returns the character encoding of the response from the Content-Type header. String The character set.



getResponseContentLength
public long getResponseContentLength()(Code)
Return the length (in bytes) of the response body, as specified in a Content-Length header.

Return -1 when the content-length is unknown.

content length, if Content-Length header is available. 0 indicates that the request has no body.If Content-Length header is not present, the method returns -1.



getResponseFooter
public Header getResponseFooter(String footerName)(Code)
Gets the response footer associated with the given name. Footer name matching is case insensitive. null will be returned if either footerName is null or there is no matching footer for footerName or there are no footers available. If there are multiple footers with the same name, there values will be combined with the ',' separator as specified by RFC2616.
Parameters:
  footerName - the footer name to match the matching footer



getResponseFooters
public Header[] getResponseFooters()(Code)
Returns an array of the response footers that the HTTP method currently has in the order in which they were read. an array of footers



getResponseHeader
public Header getResponseHeader(String headerName)(Code)
Gets the response header associated with the given name. Header name matching is case insensitive. null will be returned if either headerName is null or there is no matching header for headerName.
Parameters:
  headerName - the header name to match the matching header



getResponseHeaderGroup
protected HeaderGroup getResponseHeaderGroup()(Code)
Gets the HeaderGroup header group storing the response headers. a HeaderGroup
since:
   2.0beta1



getResponseHeaders
public Header[] getResponseHeaders(String headerName)(Code)

See Also:   org.apache.commons.httpclient.HttpMethod.getResponseHeaders(java.lang.String)
since:
   3.0



getResponseHeaders
public Header[] getResponseHeaders()(Code)
Returns an array of the response headers that the HTTP method currently has in the order in which they were read. an array of response headers.



getResponseStream
protected InputStream getResponseStream()(Code)
Returns a stream from which the body of the current response may be read. If the method has not yet been executed, if responseBodyConsumed has been called, or if the stream returned by a previous call has been closed, null will be returned. the current response stream



getResponseTrailerHeaderGroup
protected HeaderGroup getResponseTrailerHeaderGroup()(Code)
Gets the HeaderGroup header group storing the response trailer headers as per RFC 2616 section 3.6.1. a HeaderGroup
since:
   2.0beta1



getStatusCode
public int getStatusCode()(Code)
Returns the response status code. the status code associated with the latest response.



getStatusLine
public StatusLine getStatusLine()(Code)
Provides access to the response status line. the status line object from the latest response.
since:
   2.0



getStatusText
public String getStatusText()(Code)
Returns the status text (or "reason phrase") associated with the latest response. The status text.



getURI
public URI getURI() throws URIException(Code)
Returns the URI of the HTTP method The URI
throws:
  URIException - If the URI cannot be created.
See Also:   org.apache.commons.httpclient.HttpMethod.getURI



hasBeenUsed
public boolean hasBeenUsed()(Code)
Returns true if the HTTP method has been already HttpMethodBase.execute executed , but not HttpMethodBase.recycle recycled . true if the method has been executed, false otherwise



isAborted
public boolean isAborted()(Code)
Tests whether the execution of this method has been aborted true if the execution of this method has been aborted,false otherwise
since:
   3.0



isConnectionCloseForced
protected boolean isConnectionCloseForced()(Code)
Tests if the connection should be force-closed when no longer needed. true if the connection must be closed



isHttp11
public boolean isHttp11()(Code)
Returns true if version 1.1 of the HTTP protocol should be used per default, false if version 1.0 should be used. true to use HTTP/1.1, false to use 1.0HttpMethodParams.getVersion



isRequestSent
public boolean isRequestSent()(Code)
Returns true if the HTTP has been transmitted to the target server in its entirety, false otherwise. This flag can be useful for recovery logic. If the request has not been transmitted in its entirety, it is safe to retry the failed method. true if the request has been sent, false otherwise



isStrictMode
public boolean isStrictMode()(Code)
org.apache.commons.httpclient.params.HttpParams.setParameter(StringObject) false



processResponseBody
protected void processResponseBody(HttpState state, HttpConnection conn)(Code)
This method is invoked immediately after HttpMethodBase.readResponseBody(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom body processing.

This implementation does nothing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
See Also:   HttpMethodBase.readResponse
See Also:   HttpMethodBase.readResponseBody



processResponseHeaders
protected void processResponseHeaders(HttpState state, HttpConnection conn)(Code)
This method is invoked immediately after HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom response headers processing.

This implementation will handle the Set-Cookie and Set-Cookie2 headers, if any, adding the relevant cookies to the given HttpState .


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
See Also:   HttpMethodBase.readResponse
See Also:   HttpMethodBase.readResponseHeaders



processStatusLine
protected void processStatusLine(HttpState state, HttpConnection conn)(Code)
This method is invoked immediately after HttpMethodBase.readStatusLine(HttpState,HttpConnection) and can be overridden by sub-classes in order to provide custom response status line processing.
Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
See Also:   HttpMethodBase.readResponse
See Also:   HttpMethodBase.readStatusLine



readResponse
protected void readResponse(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Reads the response from the given HttpConnection connection .

The response is processed as the following sequence of actions:

  1. HttpMethodBase.readStatusLine(HttpState,HttpConnection) is invoked to read the request line.
  2. HttpMethodBase.processStatusLine(HttpState,HttpConnection) is invoked, allowing the method to process the status line if desired.
  3. HttpMethodBase.readResponseHeaders(HttpState,HttpConnection) is invoked to read the associated headers.
  4. HttpMethodBase.processResponseHeaders(HttpState,HttpConnection) is invoked, allowing the method to process the headers if desired.
  5. HttpMethodBase.readResponseBody(HttpState,HttpConnection) is invoked to read the associated body (if any).
  6. HttpMethodBase.processResponseBody(HttpState,HttpConnection) is invoked, allowing the method to process the response body if desired.
Subclasses may want to override one or more of the above methods to to customize the processing. (Or they may choose to override this method if dramatically different processing is required.)


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



readResponseBody
protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Read the response body from the given 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.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   HttpMethodBase.readResponse
See Also:   HttpMethodBase.processResponseBody



readResponseHeaders
protected void readResponseHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Reads the response headers from the given HttpConnection connection .

Subclasses may want to override this method to to customize the processing.

"It must be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma." - HTTP/1.0 (4.3)


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   HttpMethodBase.readResponse
See Also:   HttpMethodBase.processResponseHeaders



readStatusLine
protected void readStatusLine(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Read the status line from the given HttpConnection , setting my HttpMethodBase.getStatusCode status code and HttpMethodBase.getStatusText statustext .

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   StatusLine



recycle
public void recycle()(Code)
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.
See Also:   HttpMethodBase.releaseConnection()



releaseConnection
public void releaseConnection()(Code)
Releases the connection being used by this HTTP method. In particular the connection is used to read the response(if there is one) and will be held until the response has been read. If the connection can be reused by other HTTP methods it is NOT closed at this point.
since:
   2.0



removeRequestHeader
public void removeRequestHeader(String headerName)(Code)
Remove the request header associated with the given name. Note that header-name matching is case insensitive.
Parameters:
  headerName - the header name



removeRequestHeader
public void removeRequestHeader(Header header)(Code)
Removes the given request header.
Parameters:
  header - the header



responseBodyConsumed
protected void responseBodyConsumed()(Code)
A response has been consumed.

The default behavior for this class is to check to see if the connection should be closed, and close if need be, and to ensure that the connection is returned to the connection manager - if and only if we are not still inside the execute call.




setConnectionCloseForced
protected void setConnectionCloseForced(boolean b)(Code)
Sets whether or not the connection should be force-closed when no longer needed. This value should only be set to true in abnormal circumstances, such as HTTP protocol violations.
Parameters:
  b - true if the connection must be closed, falseotherwise.



setDoAuthentication
public void setDoAuthentication(boolean doAuthentication)(Code)
Sets whether or not the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.)
Parameters:
  doAuthentication - true to process authentication challengesauthomatically, false otherwise.
since:
   2.0



setFollowRedirects
public void setFollowRedirects(boolean followRedirects)(Code)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.)
Parameters:
  followRedirects - true if the method will automatically follow redirects,false otherwise.



setHostConfiguration
public void setHostConfiguration(HostConfiguration hostconfig)(Code)
Sets the HostConfiguration host configuration .
Parameters:
  hostconfig - The hostConfiguration to set



setHttp11
public void setHttp11(boolean http11)(Code)
Sets whether version 1.1 of the HTTP protocol should be used per default.
Parameters:
  http11 - true to use HTTP/1.1, false to use 1.0HttpMethodParams.setVersion(HttpVersion)



setMethodRetryHandler
public void setMethodRetryHandler(MethodRetryHandler handler)(Code)
Sets the MethodRetryHandler retry handler for this HTTP method
Parameters:
  handler - the methodRetryHandler to use when this method executedHttpMethodParams



setParams
public void setParams(HttpMethodParams params)(Code)
Assigns HttpMethodParams HTTP protocol parameters for this method.
since:
   3.0
See Also:   HttpMethodParams



setPath
public void setPath(String path)(Code)
Sets the path of the HTTP method. It is responsibility of the caller to ensure that the path is properly encoded (URL safe).
Parameters:
  path - the path of the HTTP method. The path is expectedto be URL-encoded



setQueryString
public void setQueryString(String queryString)(Code)
Sets the query string of this HTTP method. The caller must ensure that the string is properly URL encoded. The query string should not start with the question mark character.
Parameters:
  queryString - the query string
See Also:   EncodingUtil.formUrlEncode(NameValuePair[]String)



setQueryString
public void setQueryString(NameValuePair[] params)(Code)
Sets the query string of this HTTP method. The pairs are encoded as UTF-8 characters. To use a different charset the parameters can be encoded manually using EncodingUtil and set as a single String.
Parameters:
  params - an array of NameValuePairs to add as query stringparameters. The name/value pairs will be automcatically URL encoded
See Also:   EncodingUtil.formUrlEncode(NameValuePair[]String)
See Also:   HttpMethodBase.setQueryString(String)



setRequestHeader
public void setRequestHeader(String headerName, String headerValue)(Code)
Set the specified request header, overwriting any previous value. Note that header-name matching is case-insensitive.
Parameters:
  headerName - the header's name
Parameters:
  headerValue - the header's value



setRequestHeader
public void setRequestHeader(Header header)(Code)
Sets the specified request header, overwriting any previous value. Note that header-name matching is case insensitive.
Parameters:
  header - the header



setResponseStream
protected void setResponseStream(InputStream responseStream)(Code)
Sets the response stream.
Parameters:
  responseStream - The new response stream.



setStrictMode
public void setStrictMode(boolean strictMode)(Code)
Defines how strictly HttpClient follows the HTTP protocol specification (RFC 2616 and other relevant RFCs). In the strict mode HttpClient precisely implements the requirements of the specification, whereas in non-strict mode it attempts to mimic the exact behaviour of commonly used HTTP agents, which many HTTP servers expect.
Parameters:
  strictMode - true for strict mode, false otherwiseorg.apache.commons.httpclient.params.HttpParams.setParameter(StringObject)



setURI
public void setURI(URI uri) throws URIException(Code)
Sets the URI for this method.
Parameters:
  uri - URI to be set
throws:
  URIException - if a URI cannot be set
since:
   3.0



shouldCloseConnection
protected boolean shouldCloseConnection(HttpConnection conn)(Code)
Tests if the connection should be closed after the method has been executed. The connection will be left open when using HTTP/1.1 or if Connection: keep-alive header was sent.
Parameters:
  conn - the connection in question boolean true if we should close the connection.



validate
public boolean validate()(Code)
Returns true the method is ready to execute, false otherwise. This implementation always returns true.



writeRequest
protected void writeRequest(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)

Sends the request via the given HttpConnection connection .

The request is written as the following sequence of actions:

  1. HttpMethodBase.writeRequestLine(HttpState,HttpConnection) is invoked to write the request line.
  2. HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection) is invoked to write the associated headers.
  3. \r\n is sent to close the head part of the request.
  4. HttpMethodBase.writeRequestBody(HttpState,HttpConnection) is invoked to write the body part of the request.

Subclasses may want to override one or more of the above methods to to customize the processing. (Or they may choose to override this method if dramatically different processing is required.)


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



writeRequestBody
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Writes the request body to the given HttpConnection connection .

This method should return true if the request body was actually sent (or is empty), or false if it could not be sent for some reason.

This implementation writes nothing and returns true.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method true
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.



writeRequestHeaders
protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Writes the request headers to the given HttpConnection connection .

This implementation invokes HttpMethodBase.addRequestHeaders(HttpState,HttpConnection) , and then writes each header to the request stream.

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   HttpMethodBase.addRequestHeaders
See Also:   HttpMethodBase.getRequestHeaders



writeRequestLine
protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException(Code)
Writes the request line to the given HttpConnection connection .

Subclasses may want to override this method to to customize the processing.


Parameters:
  state - the HttpState state information associated with this method
Parameters:
  conn - the HttpConnection connection used to executethis HTTP method
throws:
  IOException - if an I/O (transport) error occurs. Some transport exceptionscan be recovered from.
throws:
  HttpException - if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
See Also:   HttpMethodBase.generateRequestLine



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.