public abstract class EntityEnclosingMethod extends ExpectContinueMethod
Modifier and Type | Field and Description |
---|---|
static long |
CONTENT_LENGTH_AUTO
Deprecated.
|
static long |
CONTENT_LENGTH_CHUNKED
Deprecated.
|
effectiveVersion, statusLine
Constructor and Description |
---|
EntityEnclosingMethod()
No-arg constructor.
|
EntityEnclosingMethod(String uri)
Constructor specifying a URI.
|
Modifier and Type | Method and Description |
---|---|
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()
Deprecated.
no longer supported and will be removed in the future
version of HttpClient
|
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)
Deprecated.
|
void |
setRequestBody(String body)
Deprecated.
|
void |
setRequestContentLength(int length)
Deprecated.
|
void |
setRequestContentLength(long length)
Deprecated.
|
void |
setRequestEntity(RequestEntity requestEntity) |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Writes the request body to the given
connection . |
getUseExpectHeader, setUseExpectHeader
abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getName, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseBody, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLine
public static final long CONTENT_LENGTH_AUTO
InputStreamRequestEntity.CONTENT_LENGTH_AUTO
.public static final long CONTENT_LENGTH_CHUNKED
setContentChunked(boolean)
.public EntityEnclosingMethod()
public EntityEnclosingMethod(String uri)
uri
- either an absolute or relative URIprotected boolean hasRequestContent()
This method must be overridden by sub-classes that implement alternative request content input methods
hasRequestContent
in class ExpectContinueMethod
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.
protected RequestEntity generateRequestEntity()
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 void setRequestContentLength(int length)
setContentChunked(boolean)
or
setRequestEntity(RequestEntity)
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.public String getRequestCharSet()
getRequestCharSet
in class HttpMethodBase
RequestEntity.getContentType()
public void setRequestContentLength(long length)
setContentChunked(boolean)
or
setRequestEntity(RequestEntity)
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.public void setContentChunked(boolean chunked)
chunked
- true
if the content should be chunkedprotected long getRequestContentLength()
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
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.
addRequestHeaders
in class ExpectContinueMethod
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodIOException
- 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.HttpMethodBase.writeRequestHeaders(edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpState, edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpConnection)
protected void addContentLengthRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException
state
- current state of http requestsconn
- the connection to use for I/OIOException
- when errors occur reading or writing to/from the
connectionHttpException
- when a recoverable error occurspublic void setRequestBody(InputStream body)
setRequestEntity(RequestEntity)
body
- Request body content as InputStream
public void setRequestBody(String body)
setRequestEntity(RequestEntity)
setRequestHeader("Content-type", "text/xml; charset=UTF-8");
default
content encoding is used (ISO-8859-1).body
- Request body content as a stringprotected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException
connection
.writeRequestBody
in class HttpMethodBase
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodIOException
- 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.public void recycle()
recycle
in interface HttpMethod
recycle
in class HttpMethodBase
HttpMethodBase.releaseConnection()
public RequestEntity getRequestEntity()
public void setRequestEntity(RequestEntity requestEntity)
requestEntity
- The requestEntity to set.Copyright © 2016 Internet2. All rights reserved.