org.apache.commons.httpclient.methods
public abstract class EntityEnclosingMethod extends ExpectContinueMethod
Since: 2.0beta1
Version: $Revision: 161963 $
Field Summary | |
---|---|
static long | CONTENT_LENGTH_AUTO
The content length will be calculated automatically. |
static long | CONTENT_LENGTH_CHUNKED
The request will use chunked transfer encoding. |
Constructor Summary | |
---|---|
EntityEnclosingMethod()
No-arg constructor.
| |
EntityEnclosingMethod(String uri)
Constructor specifying a URI.
|
Method Summary | |
---|---|
protected void | addContentLengthRequestHeader(HttpState state, HttpConnection conn)
Generates Content-Length or Transfer-Encoding: Chunked
request header, as long as no Content-Length request header
already exists.
|
protected void | addRequestHeaders(HttpState state, HttpConnection conn)
Populates the request headers map to with additional
headers to be submitted to
the given HttpConnection.
|
protected void | clearRequestBody()
Clears the request body.
|
protected byte[] | generateRequestBody()
Generates the request body.
|
protected RequestEntity | generateRequestEntity() |
boolean | getFollowRedirects()
Entity enclosing requests cannot be redirected without user intervention
according to RFC 2616.
|
String | getRequestCharSet()
Returns the request's charset. |
protected long | getRequestContentLength()
Returns the length of the request body.
|
RequestEntity | getRequestEntity() |
protected boolean | hasRequestContent()
Returns true if there is a request body to be sent.
|
void | recycle()
Recycles the HTTP method so that it can be used again.
|
void | setContentChunked(boolean chunked)
Sets whether or not the content should be chunked.
|
void | setFollowRedirects(boolean followRedirects)
Entity enclosing requests cannot be redirected without user intervention
according to RFC 2616.
|
void | setRequestBody(InputStream body)
Sets the request body to be the specified inputstream.
|
void | setRequestBody(String body)
Sets the request body to be the specified string.
|
void | setRequestContentLength(int length)
Sets length information about the request body.
|
void | setRequestContentLength(long length)
Sets length information about the request body.
|
void | setRequestEntity(RequestEntity requestEntity) |
protected boolean | writeRequestBody(HttpState state, HttpConnection conn)
Writes the request body to the given connection .
|
Deprecated: Use CONTENT_LENGTH_AUTO.
The content length will be calculated automatically. This implies buffering of the content.Deprecated: Use EntityEnclosingMethod.
The request will use chunked transfer encoding. Content length is not calculated and the content is not buffered.Since: 2.0
Parameters: uri either an absolute or relative URI
Since: 2.0
Parameters: state current state of http requests conn the connection to use for I/O
Throws: IOException when errors occur reading or writing to/from the connection HttpException when a recoverable error occurs
headers
to be submitted to
the given HttpConnection.
This implementation adds tt>Content-Length or Transfer-Encoding headers.
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 state
information associated with this method conn the connection
used to execute
this HTTP method
Throws: 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.
Since: 3.0
See Also: EntityEnclosingMethod
This method must be overridden by sub-classes that implement alternative request content input methods.
Since: 2.0beta1
This method must be overridden by sub-classes that implement alternative request content input methods.
Returns: request body as an array of bytes. If the request content has not been set, returns null.
Since: 2.0beta1
Returns: false
.
Since: 2.0
Since: 3.0
Returns: number of bytes in the request body
Returns: Returns the requestEntity.
Since: 3.0
This method must be overridden by sub-classes that implement alternative request content input methods
Returns: boolean
Since: 2.0beta1
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.Parameters: chunked true
if the content should be chunked
Since: 3.0
Parameters: followRedirects must always be false
Deprecated: use setRequestEntity
Sets the request body to be the specified inputstream.Parameters: body Request body content as java.io.InputStream
Deprecated: use setRequestEntity
Sets the request body to be the specified string. The string will be submitted, using the encoding specified in the Content-Type request header.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
default
content encoding is used (ISO-8859-1).
Parameters: body Request body content as a string
Deprecated: Use EntityEnclosingMethod or setRequestEntity
Sets length information about the request body.Note: If you specify a content length the request is unbuffered. This prevents redirection and automatic retry if a request fails the first time. This means that the HttpClient can not perform authorization automatically but will throw an Exception. You will have to set the necessary 'Authorization' or 'Proxy-Authorization' headers manually.
Parameters: length size in bytes or any of CONTENT_LENGTH_AUTO, CONTENT_LENGTH_CHUNKED. If number of bytes or CONTENT_LENGTH_CHUNKED is specified the content will not be buffered internally and the Content-Length header of the request will be used. In this case the user is responsible to supply the correct content length. If CONTENT_LENGTH_AUTO is specified the request will be buffered before it is sent over the network.
Deprecated: Use EntityEnclosingMethod or setRequestEntity
Sets length information about the request body.Note: If you specify a content length the request is unbuffered. This prevents redirection and automatic retry if a request fails the first time. This means that the HttpClient can not perform authorization automatically but will throw an Exception. You will have to set the necessary 'Authorization' or 'Proxy-Authorization' headers manually.
Parameters: length size in bytes or any of CONTENT_LENGTH_AUTO, CONTENT_LENGTH_CHUNKED. If number of bytes or CONTENT_LENGTH_CHUNKED is specified the content will not be buffered internally and the Content-Length header of the request will be used. In this case the user is responsible to supply the correct content length. If CONTENT_LENGTH_AUTO is specified the request will be buffered before it is sent over the network.
Parameters: requestEntity The requestEntity to set.
Since: 3.0
connection
.
Parameters: state the state
information associated with this method conn the connection
used to execute
this HTTP method
Returns: true
Throws: 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.