|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.HttpMethodBase | +--org.apache.commons.httpclient.methods.GetMethod | +--org.apache.commons.httpclient.methods.ExpectContinueMethod | +--org.apache.commons.httpclient.methods.EntityEnclosingMethod
This abstract class serves as a foundation for all HTTP methods that can enclose an entity within requests
Field Summary | |
static int |
CONTENT_LENGTH_AUTO
The content length will be calculated automatically. |
static int |
CONTENT_LENGTH_CHUNKED
The request will use chunked transfer encoding. |
Fields inherited from class org.apache.commons.httpclient.HttpMethodBase |
USER_AGENT |
Constructor Summary | |
EntityEnclosingMethod()
No-arg constructor. |
|
EntityEnclosingMethod(java.lang.String uri)
Constructor specifying a URI. |
|
EntityEnclosingMethod(java.lang.String uri,
java.lang.String tempDir)
Deprecated. the client is responsible for disk I/O |
|
EntityEnclosingMethod(java.lang.String uri,
java.lang.String tempDir,
java.lang.String tempFile)
Deprecated. the client is responsible for disk I/O |
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 |
clearRequestBody()
Clears request body. |
protected byte[] |
generateRequestBody()
Generates request body. |
boolean |
getFollowRedirects()
Entity enclosing requests cannot be redirected without user intervention according to RFC 2616. |
java.io.InputStream |
getRequestBody()
Returns the request body as a InputStream . |
java.lang.String |
getRequestBodyAsString()
Returns the request body as a String . |
protected int |
getRequestContentLength()
Overrides method of HttpMethodBase
to return the length of the request body. |
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 |
setFollowRedirects(boolean followRedirects)
Entity enclosing requests cannot be redirected without user intervention according to RFC 2616. |
void |
setRequestBody(java.io.InputStream body)
Sets the request body to be the specified inputstream. |
void |
setRequestBody(java.lang.String body)
Sets the request body to be the specified string. |
void |
setRequestContentLength(int length)
Sets length information about the request body. |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Writes the request body to the given connection . |
Methods inherited from class org.apache.commons.httpclient.methods.ExpectContinueMethod |
addRequestHeaders,
getUseExpectHeader,
setUseExpectHeader |
Methods inherited from class org.apache.commons.httpclient.methods.GetMethod |
getFileData,
getName,
getTempDir,
getTempFile,
getUseDisk,
readResponseBody,
setFileData,
setTempDir,
setTempFile,
setUseDisk |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int CONTENT_LENGTH_AUTO
public static final int CONTENT_LENGTH_CHUNKED
Constructor Detail |
public EntityEnclosingMethod()
public EntityEnclosingMethod(java.lang.String uri)
uri
- either an absolute or relative URIpublic EntityEnclosingMethod(java.lang.String uri, java.lang.String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic EntityEnclosingMethod(java.lang.String uri, java.lang.String tempDir, java.lang.String tempFile)
uri
- either an absolute or relative URItempDir
- directory to store temp files intempFile
- file to store temporary data inMethod Detail |
protected boolean hasRequestContent()
This method must be overridden by sub-classes that implement alternative request content input methods
protected void clearRequestBody()
This method must be overridden by sub-classes that implement alternative request content input methods.
protected byte[] generateRequestBody()
This method must be overridden by sub-classes that implement alternative request content input methods.
public boolean getFollowRedirects()
false
.public void setFollowRedirects(boolean followRedirects)
followRedirects
- must always be false
public void setRequestContentLength(int length)
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.
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.protected int getRequestContentLength()
HttpMethodBase
to return the length of the request body.protected void addContentLengthRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodpublic void setRequestBody(java.io.InputStream body)
body
- Request body content as InputStream
public java.io.InputStream getRequestBody()
InputStream
.
Calling this method will cause the content to be buffered.InputStream
if it has been set.public void setRequestBody(java.lang.String body)
setRequestHeader("Content-type", "text/xml; charset=UTF-8");
default
content encoding is used (ISO-8859-1).body
- Request body content as a stringpublic java.lang.String getRequestBodyAsString() throws java.io.IOException
String
.
Calling this method will cause the content to be buffered.String
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodpublic void recycle()
HttpMethodBase.releaseConnection()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |