public abstract class EntityEnclosingMethod extends ExpectContinueMethod
| 限定符和类型 | 字段和说明 |
|---|---|
static long |
CONTENT_LENGTH_AUTO
|
static long |
CONTENT_LENGTH_CHUNKED
已过时。
|
| 构造器和说明 |
|---|
EntityEnclosingMethod()
No-arg constructor.
|
EntityEnclosingMethod(String uri)
Constructor specifying a URI.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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()
已过时。
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)
已过时。
|
void |
setRequestBody(String body)
已过时。
|
void |
setRequestContentLength(int length)
|
void |
setRequestContentLength(long length)
|
void |
setRequestEntity(RequestEntity requestEntity) |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Writes the request body to the given
connection. |
getUseExpectHeader, setUseExpectHeaderabort, 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, getResponseBodyAsStream, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, 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, writeRequestLinepublic static final long 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 在类中 ExpectContinueMethodprotected 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 在接口中 HttpMethodgetFollowRedirects 在类中 HttpMethodBasefalse.public void setFollowRedirects(boolean followRedirects)
setFollowRedirects 在接口中 HttpMethodsetFollowRedirects 在类中 HttpMethodBasefollowRedirects - must always be falsepublic 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.public String getRequestCharSet()
getRequestCharSet 在类中 HttpMethodBaseRequestEntity.getContentType()public void setRequestContentLength(long 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.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 在类中 ExpectContinueMethodstate - 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(com.ptteng.course.util.aliPayUtil.apacheCommonUtil.httpclient.HttpState, com.ptteng.course.util.aliPayUtil.apacheCommonUtil.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 InputStreampublic 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 在类中 HttpMethodBasestate - 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 在接口中 HttpMethodrecycle 在类中 HttpMethodBaseHttpMethodBase.releaseConnection()public RequestEntity getRequestEntity()
public void setRequestEntity(RequestEntity requestEntity)
requestEntity - The requestEntity to set.Copyright © 2017. All rights reserved.