org.apache.commons.httpclient.methods
abstract public class: ExpectContinueMethod [javadoc |
source]
java.lang.Object
org.apache.commons.httpclient.HttpMethodBase
org.apache.commons.httpclient.methods.ExpectContinueMethod
All Implemented Interfaces:
HttpMethod
Direct Known Subclasses:
PutMethod, NoncompliantPostMethod, PostMethod, EntityEnclosingMethod, UrlPostMethod, MultipartPostMethod, UrlPutMethod
This abstract class serves as a foundation for all HTTP methods
that support 'Expect: 100-continue' handshake.
The purpose of the 100 (Continue) status (refer to section 10.1.1
of the RFC 2616 for more details) is to allow a client that is
sending a request message with a request body to determine if the
origin server is willing to accept the request (based on the request
headers) before the client sends the request body. In some cases,
it might either be inappropriate or highly inefficient for the
client to send the body if the server will reject the message
without looking at the body.
'Expect: 100-continue' handshake should be used with caution,
as it may cause problems with HTTP servers and proxies that
do not support HTTP/1.1 protocol.
- author:
< - a href="mailto:oleg@ural.ru">Oleg Kalnichevski
- since:
2.0beta1 -
| Methods from org.apache.commons.httpclient.HttpMethodBase: |
|---|
|
abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addRequestHeaders, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, fakeResponse, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getName, getParams, getPath, getProxyAuthState, getProxyAuthenticationRealm, getQueryString, getRecoverableExceptionCount, getRequestCharSet, 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, recycle, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestBody, writeRequestHeaders, writeRequestLine |
| Method from org.apache.commons.httpclient.methods.ExpectContinueMethod Detail: |
protected void addRequestHeaders(HttpState state,
HttpConnection conn) throws IOException, HttpException {
LOG.trace("enter ExpectContinueMethod.addRequestHeaders(HttpState, HttpConnection)");
super.addRequestHeaders(state, conn);
// If the request is being retried, the header may already be present
boolean headerPresent = (getRequestHeader("Expect") != null);
// See if the expect header should be sent
// = HTTP/1.1 or higher
// = request body present
if (getParams().isParameterTrue(HttpMethodParams.USE_EXPECT_CONTINUE)
&& getEffectiveVersion().greaterEquals(HttpVersion.HTTP_1_1)
&& hasRequestContent())
{
if (!headerPresent) {
setRequestHeader("Expect", "100-continue");
}
} else {
if (headerPresent) {
removeRequestHeader("Expect");
}
}
}
Sets the Expect header if it has not already been set,
in addition to the "standard" set of headers. |
public boolean getUseExpectHeader() {
return getParams().getBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, false);
} Deprecated! Use - HttpMethodParams
Returns true if the 'Expect: 100-Continue' handshake
is activated. The purpose of the 'Expect: 100-Continue'
handshake to allow a client that is sending a request message
with a request body to determine if the origin server is
willing to accept the request (based on the request headers)
before the client sends the request body.
|
abstract protected boolean hasRequestContent()
Returns true if there is a request body to be sent.
'Expect: 100-continue' handshake may not be used if request
body is not present |
public void setUseExpectHeader(boolean value) {
getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, value);
} Deprecated! Use - HttpMethodParams
Activates 'Expect: 100-Continue' handshake. The purpose of
the 'Expect: 100-Continue' handshake to allow a client that is
sending a request message with a request body to determine if
the origin server is willing to accept the request (based on
the request headers) before the client sends the request body.
The use of the 'Expect: 100-continue' handshake can result in
noticable peformance improvement for entity enclosing requests
(such as POST and PUT) that require the target server's
authentication.
'Expect: 100-continue' handshake should be used with
caution, as it may cause problems with HTTP servers and
proxies that do not support HTTP/1.1 protocol.
|