From: <rb...@us...> - 2015-06-17 19:11:46
|
Revision: 10739 http://sourceforge.net/p/htmlunit/code/10739 Author: rbri Date: 2015-06-17 19:11:44 +0000 (Wed, 17 Jun 2015) Log Message: ----------- revert some changed, it seems to be more complicated 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 2015-06-17 18:20:27 UTC (rev 10738) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2015-06-17 19:11:44 UTC (rev 10739) @@ -83,6 +83,7 @@ import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.LayeredConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.cookie.CookieSpec; import org.apache.http.cookie.CookieSpecProvider; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; @@ -96,7 +97,7 @@ import org.apache.http.protocol.RequestTargetHost; import org.apache.http.ssl.SSLContexts; -import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitCookieSpecProvider; +import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitBrowserCompatCookieSpec; import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitCookieStore; import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitRedirectStrategie; import com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory; @@ -143,7 +144,12 @@ */ public HttpWebConnection(final WebClient webClient) { webClient_ = webClient; - htmlUnitCookieSpecProvider_ = new HtmlUnitCookieSpecProvider(webClient.getBrowserVersion()); + htmlUnitCookieSpecProvider_ = new CookieSpecProvider() { + @Override + public CookieSpec create(final HttpContext context) { + return new HtmlUnitBrowserCompatCookieSpec(webClient.getBrowserVersion()); + } + }; httpContext_ = new HttpClientContext(); usedOptions_ = new WebClientOptions(); } @@ -163,7 +169,7 @@ HttpUriRequest httpMethod = null; try { try { - httpMethod = makeHttpMethod(request, builder); + httpMethod = makeHttpMethod(request); } catch (final URISyntaxException e) { throw new IOException("Unable to create URI from URL: " + url.toExternalForm() @@ -246,13 +252,12 @@ /** * Creates an <tt>HttpMethod</tt> instance according to the specified parameters. * @param webRequest the request - * @param httpClientBuilder the httpClientBuilder that will be configured * @return the <tt>HttpMethod</tt> instance constructed according to the specified parameters * @throws IOException * @throws URISyntaxException */ @SuppressWarnings("deprecation") - private HttpUriRequest makeHttpMethod(final WebRequest webRequest, final HttpClientBuilder httpClientBuilder) + private HttpUriRequest makeHttpMethod(final WebRequest webRequest) throws IOException, URISyntaxException { final String charset = webRequest.getCharset(); @@ -326,8 +331,10 @@ } } - configureHttpProcessorBuilder(httpClientBuilder, webRequest); + final HttpClientBuilder httpClient = getHttpClientBuilder(); + configureHttpProcessor(httpClient, webRequest); + // Tell the client where to get its credentials from // (it may have changed on the webClient since last call to getHttpClientFor(...)) final CredentialsProvider credentialsProvider = webClient_.getCredentialsProvider(); @@ -352,7 +359,7 @@ credentialsProvider.setCredentials(authScope, requestCredentials); httpContext_.removeAttribute(HttpClientContext.TARGET_AUTH_STATE); } - httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); + httpClient.setDefaultCredentialsProvider(credentialsProvider); httpContext_.removeAttribute(HttpClientContext.CREDS_PROVIDER); return httpMethod; @@ -512,12 +519,12 @@ } /** - * Creates the <tt>HttpClientBuilder</tt> that will be used by this WebClient. + * Creates the <tt>HttpClient</tt> that will be used by this WebClient. * Extensions may override this method in order to create a customized - * <tt>HttpClientBuilder</tt> instance (e.g. with a custom + * <tt>HttpClient</tt> instance (e.g. with a custom * {@link org.apache.http.conn.ClientConnectionManager} to perform * some tracking; see feature request 1438216). - * @return the <tt>HttpClientBuilder</tt> that will be used by this WebConnection + * @return the <tt>HttpClient</tt> that will be used by this WebConnection */ protected HttpClientBuilder createHttpClient() { final HttpClientBuilder builder = HttpClientBuilder.create(); @@ -601,7 +608,7 @@ usedOptions_.setProxyConfig(options.getProxyConfig()); } - private void configureHttpProcessorBuilder(final HttpClientBuilder builder, final WebRequest webRequest) + private void configureHttpProcessor(final HttpClientBuilder builder, final WebRequest webRequest) throws IOException { final HttpProcessorBuilder b = HttpProcessorBuilder.create(); for (final HttpRequestInterceptor i : getHttpRequestInterceptors(webRequest)) { |