From: <rb...@us...> - 2014-03-09 16:26:11
|
Revision: 9170 http://sourceforge.net/p/htmlunit/code/9170 Author: rbri Date: 2014-03-09 16:26:08 +0000 (Sun, 09 Mar 2014) Log Message: ----------- try to cleanup the code, always do the configuration in the same order Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2014-03-08 22:01:16 UTC (rev 9169) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2014-03-09 16:26:08 UTC (rev 9170) @@ -133,10 +133,10 @@ private final WebClient webClient_; /** Use single HttpContext, so there is no need to re-send authentication for each and every request. */ - private HttpContext httpContext_ = new HttpClientContext(); + private final HttpContext httpContext_; private String virtualHost_; private final CookieSpecProvider htmlUnitCookieSpecProvider_; - private final WebClientOptions usedOptions_ = new WebClientOptions(); + private final WebClientOptions usedOptions_; /** * Creates a new HTTP web connection instance. @@ -150,6 +150,8 @@ return new HtmlUnitBrowserCompatCookieSpec(webClient_.getIncorrectnessListener()); } }; + httpContext_ = new HttpClientContext(); + usedOptions_ = new WebClientOptions(); } /** @@ -386,10 +388,9 @@ credentialsProvider.setCredentials(authScope, requestCredentials); httpContext_.removeAttribute(HttpClientContext.TARGET_AUTH_STATE); } + httpClient.setDefaultCredentialsProvider(credentialsProvider); httpContext_.removeAttribute(HttpClientContext.CREDS_PROVIDER); - httpClient.setDefaultCredentialsProvider(credentialsProvider); - httpContext_.removeAttribute(HttpClientContext.COOKIE_STORE); if (webClient_.getCookieManager().isCookiesEnabled()) { // Cookies are enabled. Note that it's important that we enable single cookie headers, // for compatibility purposes. @@ -408,6 +409,8 @@ } }); } + httpContext_.removeAttribute(HttpClientContext.COOKIE_STORE); + return httpMethod; } |