Moved the default context initialization code to the DefaultHttpClient#createHttpContext method; replaced synchronized HttpContext impl with a non synchronized one: there is a new instance of HttpContext created for each request, there is no point to synchronize access to it

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@677250 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2008-07-16 11:45:47 +00:00
parent e410739b7d
commit 02c04ffe73
2 changed files with 16 additions and 16 deletions

View File

@ -57,7 +57,6 @@ import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.RedirectHandler;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.routing.HttpRoutePlanner;
@ -531,19 +530,6 @@ public abstract class AbstractHttpClient implements HttpClient {
synchronized (this) {
HttpContext defaultContext = createHttpContext();
defaultContext.setAttribute(
ClientContext.AUTHSCHEME_REGISTRY,
getAuthSchemes());
defaultContext.setAttribute(
ClientContext.COOKIESPEC_REGISTRY,
getCookieSpecs());
defaultContext.setAttribute(
ClientContext.COOKIE_STORE,
getCookieStore());
defaultContext.setAttribute(
ClientContext.CREDS_PROVIDER,
getCredentialsProvider());
if (context == null) {
execContext = defaultContext;
} else {

View File

@ -43,6 +43,7 @@ import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.client.protocol.RequestAddCookies;
import org.apache.http.client.protocol.RequestDefaultHeaders;
import org.apache.http.client.protocol.RequestProxyAuthentication;
@ -70,6 +71,7 @@ import org.apache.http.impl.cookie.RFC2965SpecFactory;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.BasicHttpProcessor;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
@ -79,7 +81,6 @@ import org.apache.http.protocol.RequestContent;
import org.apache.http.protocol.RequestExpectContinue;
import org.apache.http.protocol.RequestTargetHost;
import org.apache.http.protocol.RequestUserAgent;
import org.apache.http.protocol.SyncBasicHttpContext;
import org.apache.http.util.VersionInfo;
@ -196,7 +197,20 @@ public class DefaultHttpClient extends AbstractHttpClient {
@Override
protected HttpContext createHttpContext() {
return new SyncBasicHttpContext(null);
HttpContext context = new BasicHttpContext();
context.setAttribute(
ClientContext.AUTHSCHEME_REGISTRY,
getAuthSchemes());
context.setAttribute(
ClientContext.COOKIESPEC_REGISTRY,
getCookieSpecs());
context.setAttribute(
ClientContext.COOKIE_STORE,
getCookieStore());
context.setAttribute(
ClientContext.CREDS_PROVIDER,
getCredentialsProvider());
return context;
}