|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | 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.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(String uri)
Constructor specifying a URI. |
|
EntityEnclosingMethod(String uri,
String tempDir)
Deprecated. the client is responsible for disk I/O |
|
EntityEnclosingMethod(String uri,
String tempDir,
String tempFile)
Deprecated. the client is responsible for disk I/O |
Method Summary | |
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn)
Set the Expect header if it has not already been set, in addition to the "standard" set of headers. |
protected void |
bufferContent()
Buffers the request body and calculates the content length. |
boolean |
getFollowRedirects()
Entity enclosing requests cannot be redirected without user intervention according to RFC 2616. |
InputStream |
getRequestBody()
Gets the request body as a stream. |
String |
getRequestBodyAsString()
Gets the request body as a String. |
protected int |
getRequestContentLength()
Override method of HttpMethodBase
to return the length of the request body. |
boolean |
getUseExpectHeader()
Returns the useExpectHeader. |
void |
recycle()
Override method of HttpMethodBase
to clear my request body. |
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 |
setUseExpectHeader(boolean value)
Sets the useExpectHeader. |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Override method of HttpMethodBase
to write request parameters as the request body. |
Methods inherited from class org.apache.commons.httpclient.methods.GetMethod |
getFileData, getName, getResponseBody, getResponseBodyAsStream, 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(String uri)
uri
- either an absolute or relative URIpublic EntityEnclosingMethod(String uri, String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic EntityEnclosingMethod(String uri, String tempDir, String tempFile)
uri
- either an absolute or relative URItempDir
- directory to store temp files intempFile
- file to store temporary data inMethod Detail |
public boolean getFollowRedirects()
getFollowRedirects
in interface HttpMethod
getFollowRedirects
in class HttpMethodBase
false
.public void setFollowRedirects(boolean followRedirects)
setFollowRedirects
in interface HttpMethod
setFollowRedirects
in class HttpMethodBase
followRedirects
- must always be false
public boolean getUseExpectHeader()
public void setUseExpectHeader(boolean value)
value
- The useExpectHeader to setpublic 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.
getRequestContentLength
in class HttpMethodBase
public void setRequestBody(InputStream body)
body
- Request body content as InputStream
public InputStream getRequestBody()
InputStream
if it has been set.public void setRequestBody(String body)
body
- Request body content as a stringpublic String getRequestBodyAsString() throws IOException
IOException
- when i/o errors occur reading the requestprotected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
addRequestHeaders
in class HttpMethodBase
state
- the client stateconn
- the connection to write to
HttpException
- when a protocol error occurs or state is invalid
IOException
- when i/o errors occur reading the responseHttpMethodBase.writeRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException
HttpMethodBase
to write request parameters as the request body. The input stream will
be truncated after the specified content length.
writeRequestBody
in class HttpMethodBase
state
- the client stateconn
- the connection to write to
IOException
- when i/o errors occur reading the response
HttpException
- when a protocol error occurs or state is invalidpublic void recycle()
HttpMethodBase
to clear my request body.
recycle
in interface HttpMethod
recycle
in class GetMethod
protected void bufferContent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |