Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.httpclient.HttpMethodBase
getName()
to return the approriate name for this method
addRequestHeaders(HttpState,HttpConnection)
to write those headers
processResponseHeaders(HttpState,HttpConnection)
to handle those headers
Constructor Summary | |
| |
|
Method Summary | |
void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
protected void |
|
void |
|
protected void |
|
protected void |
|
protected void | |
int |
|
protected static String |
|
String |
|
protected String |
|
boolean |
|
HttpVersion |
|
boolean |
|
AuthState |
|
HostConfiguration |
|
MethodRetryHandler |
|
abstract String |
|
HttpMethodParams |
|
String |
|
AuthState |
|
String |
|
String |
|
int |
|
String |
|
Header |
|
protected HeaderGroup |
|
Header[] |
|
Header[] |
|
byte[] |
|
InputStream |
|
String |
|
String |
|
long |
|
Header |
|
Header[] |
|
Header |
|
protected HeaderGroup |
|
Header[] |
|
Header[] |
|
protected InputStream |
|
protected HeaderGroup |
|
int |
|
StatusLine |
|
String |
|
URI |
|
boolean |
|
boolean |
|
protected boolean |
|
boolean |
|
boolean |
|
boolean |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
void |
|
void | |
protected boolean |
|
boolean |
|
protected void |
|
protected boolean |
|
protected void |
|
protected void |
|
public HttpMethodBase()
No-arg constructor.
public HttpMethodBase(String uri) throws IllegalArgumentException, IllegalStateException
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 expected to be URL-encoded
public void abort()
Aborts the execution of this method.
- Specified by:
- abort in interface HttpMethod
- Since:
- 3.0
protected void addCookieRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException
Generates Cookie request headers for thosecookie
s that match the given host, port and path.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void addHostRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException
Generates Host request header, as long as no Host request header already exists.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void addProxyConnectionHeader(HttpState state, HttpConnection conn) throws IOException, HttpException
Generates Proxy-Connection: Keep-Alive request header when communicating via a proxy server.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
public void addRequestHeader(String headerName, String headerValue)
Adds the specified request header, NOT overwriting any previous value. Note that header-name matching is case insensitive.
- Specified by:
- addRequestHeader in interface HttpMethod
- Parameters:
headerName
- the header's nameheaderValue
- the header's value
public void addRequestHeader(Header header)
Adds the specified request header, NOT overwriting any previous value. Note that header-name matching is case insensitive.
- Specified by:
- addRequestHeader in interface HttpMethod
- Parameters:
header
- the header to add to the request
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
Generates all the required requestheader
s to be submitted via the givenconnection
. 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
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
public void addResponseFooter(Header footer)
Use this method internally to add footers.
- Specified by:
- addResponseFooter in interface HttpMethod
- Parameters:
footer
- The footer to add.
protected void addUserAgentRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException
Generates default User-Agent request header, as long as no User-Agent request header already exists.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void checkNotUsed() throws IllegalStateException
protected void checkUsed() throws IllegalStateException
public int execute(HttpState state, HttpConnection conn) throws HttpException, IOException
Executes this method using the specifiedHttpConnection
andHttpState
.
- Specified by:
- execute in interface HttpMethod
- Parameters:
state
-state
information to associate with this request. Must be non-null.conn
- theconnection
to used to execute this HTTP method. Must be non-null.
- Returns:
- the integer status code if one was obtained, or -1
- Throws:
HttpException
- if a protocol exception occurs.
protected static String generateRequestLine(HttpConnection connection, String name, String requestPath, String query, String version)
Generates HTTP request line according to the specified attributes.
- Parameters:
connection
- theconnection
used to execute this HTTP methodname
- the method name generate a request forrequestPath
- the path string for the requestquery
- the query string for the requestversion
- the protocol version to use (e.g. HTTP/1.0)
- Returns:
- HTTP request line
public String getAuthenticationRealm()
Deprecated. use #getHostAuthState()
Returns authentication realm, if it has been used during authentication process. Otherwise returns null.
- Returns:
- authentication realm
protected String getContentCharSet(Header contentheader)
Returns the character set from the Content-Type header.
- Parameters:
contentheader
- The content header.
- Returns:
- String The character set.
public boolean getDoAuthentication()
Returns true if the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.), false otherwise
- Specified by:
- getDoAuthentication in interface HttpMethod
- Returns:
- true if authentication challenges will be processed automatically, false otherwise.
- Since:
- 2.0
public HttpVersion getEffectiveVersion()
Returns the HTTP version used with this method (may be null if undefined, that is, the method has not been executed)
- Returns:
- HTTP version.
- Since:
- 3.0
public boolean getFollowRedirects()
Returns true if the HTTP method should automatically follow HTTP redirects (status code 302, etc.), false otherwise.
- Specified by:
- getFollowRedirects in interface HttpMethod
- Returns:
- true if the method will automatically follow HTTP redirects, false otherwise.
public AuthState getHostAuthState()
Returns the target hostauthentication state
- Specified by:
- getHostAuthState in interface HttpMethod
- Returns:
- host authentication state
- Since:
- 3.0
public HostConfiguration getHostConfiguration()
Deprecated. no longer applicable
Returns thehost configuration
.
- Specified by:
- getHostConfiguration in interface HttpMethod
- Returns:
- the host configuration
public MethodRetryHandler getMethodRetryHandler()
Deprecated. use
HttpMethodParams
Returns theretry handler
for this HTTP method
- Returns:
- the methodRetryHandler
public abstract String getName()
Obtains the name of the HTTP method as used in the HTTP request line, for example "GET" or "POST".
- Specified by:
- getName in interface HttpMethod
- Returns:
- the name of this method
public HttpMethodParams getParams()
ReturnsHTTP protocol parameters
associated with this method.
- Specified by:
- getParams in interface HttpMethod
- Returns:
- HTTP parameters.
- Since:
- 3.0
public String getPath()
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.
- Specified by:
- getPath in interface HttpMethod
- Returns:
- the path to request or "/" if the path is blank.
public AuthState getProxyAuthState()
Returns the proxyauthentication state
- Specified by:
- getProxyAuthState in interface HttpMethod
- Returns:
- host authentication state
- Since:
- 3.0
public String getProxyAuthenticationRealm()
Deprecated. use #getProxyAuthState()
Returns proxy authentication realm, if it has been used during authentication process. Otherwise returns null.
- Returns:
- proxy authentication realm
public String getQueryString()
Gets the query string of this HTTP method.
- Specified by:
- getQueryString in interface HttpMethod
- Returns:
- The query string
public int getRecoverableExceptionCount()
Deprecated. no longer used Returns the number of "recoverable" exceptions thrown and handled, to allow for monitoring the quality of the connection.
- Returns:
- The number of recoverable exceptions handled by the method.
public String getRequestCharSet()
Returns the character encoding of the request from the Content-Type header.
- Returns:
- String The character set.
public Header getRequestHeader(String headerName)
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.
- Specified by:
- getRequestHeader in interface HttpMethod
- Parameters:
headerName
- The name of the header to be returned.
- Returns:
- The specified request header.
- Since:
- 3.0
protected HeaderGroup getRequestHeaderGroup()
Gets theheader group
storing the request headers.
- Returns:
- a HeaderGroup
- Since:
- 2.0beta1
public Header[] getRequestHeaders()
Returns an array of the requests headers that the HTTP method currently has
- Specified by:
- getRequestHeaders in interface HttpMethod
- Returns:
- an array of my request headers.
public Header[] getRequestHeaders(String headerName)
- Specified by:
- getRequestHeaders in interface HttpMethod
- See Also:
org.apache.commons.httpclient.HttpMethod.getRequestHeaders(java.lang.String)
public byte[] getResponseBody() throws IOException
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.
- Specified by:
- getResponseBody in interface HttpMethod
- Returns:
- The response body.
public InputStream getResponseBodyAsStream() throws IOException
Returns the response body of the HTTP method, if any, as anInputStream
. If response body is not available, returns null
- Specified by:
- getResponseBodyAsStream in interface HttpMethod
- Returns:
- The response body
public String getResponseBodyAsString() throws IOException
Returns the response body of the HTTP method, if any, as aString
. 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.
- Specified by:
- getResponseBodyAsString in interface HttpMethod
- Returns:
- The response body.
public String getResponseCharSet()
Returns the character encoding of the response from the Content-Type header.
- Returns:
- String The character set.
public long getResponseContentLength()
Return the length (in bytes) of the response body, as specified in a Content-Length header. Return -1 when the content-length is unknown.
- Returns:
- 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.
public Header getResponseFooter(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. If there are multiple footers with the same name, there values will be combined with the ',' separator as specified by RFC2616.
- Specified by:
- getResponseFooter in interface HttpMethod
- Parameters:
footerName
- the footer name to match
- Returns:
- the matching footer
public Header[] getResponseFooters()
Returns an array of the response footers that the HTTP method currently has in the order in which they were read.
- Specified by:
- getResponseFooters in interface HttpMethod
- Returns:
- an array of footers
public Header getResponseHeader(String headerName)
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.
- Specified by:
- getResponseHeader in interface HttpMethod
- Parameters:
headerName
- the header name to match
- Returns:
- the matching header
protected HeaderGroup getResponseHeaderGroup()
Gets theheader group
storing the response headers.
- Returns:
- a HeaderGroup
- Since:
- 2.0beta1
public Header[] getResponseHeaders()
Returns an array of the response headers that the HTTP method currently has in the order in which they were read.
- Specified by:
- getResponseHeaders in interface HttpMethod
- Returns:
- an array of response headers.
public Header[] getResponseHeaders(String headerName)
- Specified by:
- getResponseHeaders in interface HttpMethod
- Since:
- 3.0
- See Also:
org.apache.commons.httpclient.HttpMethod.getResponseHeaders(java.lang.String)
protected InputStream getResponseStream()
Returns a stream from which the body of the current response may be read. If the method has not yet been executed, ifresponseBodyConsumed
has been called, or if the stream returned by a previous call has been closed,null
will be returned.
- Returns:
- the current response stream
protected HeaderGroup getResponseTrailerHeaderGroup()
Gets theheader group
storing the response trailer headers as per RFC 2616 section 3.6.1.
- Returns:
- a HeaderGroup
- Since:
- 2.0beta1
public int getStatusCode()
Returns the response status code.
- Specified by:
- getStatusCode in interface HttpMethod
- Returns:
- the status code associated with the latest response.
public StatusLine getStatusLine()
Provides access to the response status line.
- Specified by:
- getStatusLine in interface HttpMethod
- Returns:
- the status line object from the latest response.
- Since:
- 2.0
public String getStatusText()
Returns the status text (or "reason phrase") associated with the latest response.
- Specified by:
- getStatusText in interface HttpMethod
- Returns:
- The status text.
public URI getURI() throws URIException
Returns the URI of the HTTP method
- Specified by:
- getURI in interface HttpMethod
- Returns:
- The URI
- Throws:
URIException
- If the URI cannot be created.
- See Also:
HttpMethod.getURI()
public boolean hasBeenUsed()
- Specified by:
- hasBeenUsed in interface HttpMethod
- Returns:
- true if the method has been executed, false otherwise
public boolean isAborted()
Tests whether the execution of this method has been aborted
- Returns:
- true if the execution of this method has been aborted, false otherwise
- Since:
- 3.0
protected boolean isConnectionCloseForced()
Tests if the connection should be force-closed when no longer needed.
- Returns:
true
if the connection must be closed
public boolean isHttp11()
Deprecated. Use
HttpMethodParams.getVersion()
Returns true if version 1.1 of the HTTP protocol should be used per default, false if version 1.0 should be used.
- Returns:
- true to use HTTP/1.1, false to use 1.0
public boolean isRequestSent()
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.
- Specified by:
- isRequestSent in interface HttpMethod
- Returns:
- true if the request has been sent, false otherwise
public boolean isStrictMode()
Deprecated. Use
HttpParams.setParameter(String,Object)
to exercise a more granular control over HTTP protocol strictness.
- Specified by:
- isStrictMode in interface HttpMethod
- Returns:
- false
protected void processResponseBody(HttpState state, HttpConnection conn)
This method is invoked immediately afterreadResponseBody(HttpState,HttpConnection)
and can be overridden by sub-classes in order to provide custom body processing. This implementation does nothing.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
protected void processResponseHeaders(HttpState state, HttpConnection conn)
This method is invoked immediately afterreadResponseHeaders(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 givenHttpState
.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
protected void processStatusLine(HttpState state, HttpConnection conn)
This method is invoked immediately afterreadStatusLine(HttpState,HttpConnection)
and can be overridden by sub-classes in order to provide custom response status line processing.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
protected void readResponse(HttpState state, HttpConnection conn) throws IOException, HttpException
Reads the response from the givenconnection
. The response is processed as the following sequence of actions: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.)
readStatusLine(HttpState,HttpConnection)
is invoked to read the request line.processStatusLine(HttpState,HttpConnection)
is invoked, allowing the method to process the status line if desired.readResponseHeaders(HttpState,HttpConnection)
is invoked to read the associated headers.processResponseHeaders(HttpState,HttpConnection)
is invoked, allowing the method to process the headers if desired.readResponseBody(HttpState,HttpConnection)
is invoked to read the associated body (if any).processResponseBody(HttpState,HttpConnection)
is invoked, allowing the method to process the response body if desired.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void readResponseBody(HttpState state, HttpConnection conn) throws IOException, HttpException
Read the response body from the givenHttpConnection
. 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
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void readResponseHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
Reads the response headers from the givenconnection
. 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
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void readStatusLine(HttpState state, HttpConnection conn) throws IOException, HttpException
Read the status line from the givenHttpConnection
, setting mystatus code
andstatus text
. Subclasses may want to override this method to to customize the processing.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
- See Also:
StatusLine
public void recycle()
Deprecated. no longer supported and will be removed in the future version of HttpClient
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.
- Specified by:
- recycle in interface HttpMethod
- See Also:
releaseConnection()
public void releaseConnection()
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.
- Specified by:
- releaseConnection in interface HttpMethod
- Since:
- 2.0
public void removeRequestHeader(String headerName)
Remove the request header associated with the given name. Note that header-name matching is case insensitive.
- Specified by:
- removeRequestHeader in interface HttpMethod
- Parameters:
headerName
- the header name
public void removeRequestHeader(Header header)
Removes the given request header.
- Specified by:
- removeRequestHeader in interface HttpMethod
- Parameters:
header
- the header
protected void responseBodyConsumed()
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.
protected void setConnectionCloseForced(boolean b)
Sets whether or not the connection should be force-closed when no longer needed. This value should only be set totrue
in abnormal circumstances, such as HTTP protocol violations.
- Parameters:
b
-true
if the connection must be closed,false
otherwise.
public void setDoAuthentication(boolean doAuthentication)
Sets whether or not the HTTP method should automatically handle HTTP authentication challenges (status code 401, etc.)
- Specified by:
- setDoAuthentication in interface HttpMethod
- Parameters:
doAuthentication
- true to process authentication challenges authomatically, false otherwise.
- Since:
- 2.0
public void setFollowRedirects(boolean followRedirects)
Sets whether or not the HTTP method should automatically follow HTTP redirects (status code 302, etc.)
- Specified by:
- setFollowRedirects in interface HttpMethod
- Parameters:
followRedirects
- true if the method will automatically follow redirects, false otherwise.
public void setHostConfiguration(HostConfiguration hostconfig)
Deprecated. no longer applicable
Sets thehost configuration
.
- Parameters:
hostconfig
- The hostConfiguration to set
public void setHttp11(boolean http11)
Deprecated. Use
HttpMethodParams.setVersion(HttpVersion)
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.0
public void setMethodRetryHandler(MethodRetryHandler handler)
Deprecated. use
HttpMethodParams
Sets theretry handler
for this HTTP method
- Parameters:
handler
- the methodRetryHandler to use when this method executed
public void setParams(HttpMethodParams params)
AssignsHTTP protocol parameters
for this method.
- Specified by:
- setParams in interface HttpMethod
- Since:
- 3.0
- See Also:
HttpMethodParams
public void setPath(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).
- Specified by:
- setPath in interface HttpMethod
- Parameters:
path
- the path of the HTTP method. The path is expected to be URL-encoded
public void setQueryString(String queryString)
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.
- Specified by:
- setQueryString in interface HttpMethod
- Parameters:
queryString
- the query string
public void setQueryString(NameValuePair[] params)
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.
- Specified by:
- setQueryString in interface HttpMethod
- Parameters:
params
- an array ofNameValuePair
s to add as query string parameters. The name/value pairs will be automcatically URL encoded
public void setRequestHeader(String headerName, String headerValue)
Set the specified request header, overwriting any previous value. Note that header-name matching is case-insensitive.
- Specified by:
- setRequestHeader in interface HttpMethod
- Parameters:
headerName
- the header's nameheaderValue
- the header's value
public void setRequestHeader(Header header)
Sets the specified request header, overwriting any previous value. Note that header-name matching is case insensitive.
- Specified by:
- setRequestHeader in interface HttpMethod
- Parameters:
header
- the header
protected void setResponseStream(InputStream responseStream)
Sets the response stream.
- Parameters:
responseStream
- The new response stream.
public void setStrictMode(boolean strictMode)
Deprecated. Use
HttpParams.setParameter(String,Object)
to exercise a more granular control over HTTP protocol strictness.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.
- Specified by:
- setStrictMode in interface HttpMethod
- Parameters:
strictMode
- true for strict mode, false otherwise
public void setURI(URI uri) throws URIException
Sets the URI for this method.
- Specified by:
- setURI in interface HttpMethod
- Parameters:
uri
- URI to be set
- Throws:
URIException
- if a URI cannot be set
- Since:
- 3.0
protected boolean shouldCloseConnection(HttpConnection conn)
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
- Returns:
- boolean true if we should close the connection.
public boolean validate()
Returns true the method is ready to execute, false otherwise.
- Specified by:
- validate in interface HttpMethod
- Returns:
- This implementation always returns true.
protected void writeRequest(HttpState state, HttpConnection conn) throws IOException, HttpException
Sends the request via the givenconnection
. The request is written as the following sequence of actions: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.)
writeRequestLine(HttpState,HttpConnection)
is invoked to write the request line.writeRequestHeaders(HttpState,HttpConnection)
is invoked to write the associated headers.- \r\n is sent to close the head part of the request.
writeRequestBody(HttpState,HttpConnection)
is invoked to write the body part of the request.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException
Writes the request body to the givenconnection
. 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
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Returns:
- true
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
protected void writeRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
Writes the request headers to the givenconnection
. This implementation invokesaddRequestHeaders(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
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.
- See Also:
addRequestHeaders(HttpState,HttpConnection)
,getRequestHeaders
protected void writeRequestLine(HttpState state, HttpConnection conn) throws IOException, HttpException
Writes the request line to the givenconnection
. Subclasses may want to override this method to to customize the processing.
- Parameters:
state
- thestate
information associated with this methodconn
- theconnection
used to execute this HTTP method
- Throws:
HttpException
- if a protocol exception occurs. Usually protocol exceptions cannot be recovered from.