Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F0A82200B21 for ; Fri, 10 Jun 2016 16:38:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF417160A15; Fri, 10 Jun 2016 14:38:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1C5C5160A38 for ; Fri, 10 Jun 2016 16:38:44 +0200 (CEST) Received: (qmail 46472 invoked by uid 500); 10 Jun 2016 14:38:39 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 46162 invoked by uid 99); 10 Jun 2016 14:38:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2016 14:38:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id BB6F6C0DD6 for ; Fri, 10 Jun 2016 14:38:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.374 X-Spam-Level: X-Spam-Status: No, score=0.374 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 5onrsDQyJ400 for ; Fri, 10 Jun 2016 14:38:37 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 1452B5FAC5 for ; Fri, 10 Jun 2016 14:38:37 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 17021E047C for ; Fri, 10 Jun 2016 14:38:36 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 14C7B3A08AE for ; Fri, 10 Jun 2016 14:38:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1747724 - in /httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http: client/params/HttpClientParamConfig.java impl/client/InternalHttpClient.java Date: Fri, 10 Jun 2016 14:38:36 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160610143836.14C7B3A08AE@svn01-us-west.apache.org> archived-at: Fri, 10 Jun 2016 14:38:46 -0000 Author: olegk Date: Fri Jun 10 14:38:35 2016 New Revision: 1747724 URL: http://svn.apache.org/viewvc?rev=1747724&view=rev Log: HTTPCLIENT-1747: apply RequestConfig defaults when using HttpParams values in backward compatibility mode Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java?rev=1747724&r1=1747723&r2=1747724&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java (original) +++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java Fri Jun 10 14:38:35 2016 @@ -51,38 +51,54 @@ public final class HttpClientParamConfig @SuppressWarnings("unchecked") public static RequestConfig getRequestConfig(final HttpParams params) { - return RequestConfig.custom() + return getRequestConfig(params, RequestConfig.DEFAULT); + } + + @SuppressWarnings("unchecked") + public static RequestConfig getRequestConfig(final HttpParams params, final RequestConfig defaultConfig) { + final RequestConfig.Builder builder = RequestConfig.copy(defaultConfig) .setSocketTimeout(params.getIntParameter( - CoreConnectionPNames.SO_TIMEOUT, 0)) + CoreConnectionPNames.SO_TIMEOUT, defaultConfig.getSocketTimeout())) .setStaleConnectionCheckEnabled(params.getBooleanParameter( - CoreConnectionPNames.STALE_CONNECTION_CHECK, true)) + CoreConnectionPNames.STALE_CONNECTION_CHECK, defaultConfig.isStaleConnectionCheckEnabled())) .setConnectTimeout(params.getIntParameter( - CoreConnectionPNames.CONNECTION_TIMEOUT, 0)) + CoreConnectionPNames.CONNECTION_TIMEOUT, defaultConfig.getConnectTimeout())) .setExpectContinueEnabled(params.getBooleanParameter( - CoreProtocolPNames.USE_EXPECT_CONTINUE, false)) - .setProxy((HttpHost) params.getParameter( - ConnRoutePNames.DEFAULT_PROXY)) - .setLocalAddress((InetAddress) params.getParameter( - ConnRoutePNames.LOCAL_ADDRESS)) - .setProxyPreferredAuthSchemes((Collection) params.getParameter( - AuthPNames.PROXY_AUTH_PREF)) - .setTargetPreferredAuthSchemes((Collection) params.getParameter( - AuthPNames.TARGET_AUTH_PREF)) + CoreProtocolPNames.USE_EXPECT_CONTINUE, defaultConfig.isExpectContinueEnabled())) .setAuthenticationEnabled(params.getBooleanParameter( - ClientPNames.HANDLE_AUTHENTICATION, true)) + ClientPNames.HANDLE_AUTHENTICATION, defaultConfig.isAuthenticationEnabled())) .setCircularRedirectsAllowed(params.getBooleanParameter( - ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false)) + ClientPNames.ALLOW_CIRCULAR_REDIRECTS, defaultConfig.isCircularRedirectsAllowed())) .setConnectionRequestTimeout((int) params.getLongParameter( - ClientPNames.CONN_MANAGER_TIMEOUT, 0)) - .setCookieSpec((String) params.getParameter( - ClientPNames.COOKIE_POLICY)) + ClientPNames.CONN_MANAGER_TIMEOUT, defaultConfig.getConnectionRequestTimeout())) .setMaxRedirects(params.getIntParameter( - ClientPNames.MAX_REDIRECTS, 50)) + ClientPNames.MAX_REDIRECTS, defaultConfig.getMaxRedirects())) .setRedirectsEnabled(params.getBooleanParameter( - ClientPNames.HANDLE_REDIRECTS, true)) + ClientPNames.HANDLE_REDIRECTS, defaultConfig.isRedirectsEnabled())) .setRelativeRedirectsAllowed(!params.getBooleanParameter( - ClientPNames.REJECT_RELATIVE_REDIRECT, false)) - .build(); + ClientPNames.REJECT_RELATIVE_REDIRECT, !defaultConfig.isRelativeRedirectsAllowed())); + + final HttpHost proxy = (HttpHost) params.getParameter(ConnRoutePNames.DEFAULT_PROXY); + if (proxy != null) { + builder.setProxy(proxy); + } + final InetAddress localAddress = (InetAddress) params.getParameter(ConnRoutePNames.LOCAL_ADDRESS); + if (localAddress != null) { + builder.setLocalAddress(localAddress); + } + final Collection targetAuthPrefs = (Collection) params.getParameter(AuthPNames.TARGET_AUTH_PREF); + if (targetAuthPrefs != null) { + builder.setTargetPreferredAuthSchemes(targetAuthPrefs); + } + final Collection proxySuthPrefs = (Collection) params.getParameter(AuthPNames.PROXY_AUTH_PREF); + if (proxySuthPrefs != null) { + builder.setProxyPreferredAuthSchemes(proxySuthPrefs); + } + final String cookiePolicy = (String) params.getParameter(ClientPNames.COOKIE_POLICY); + if (cookiePolicy != null) { + builder.setCookieSpec(cookiePolicy); + } + return builder.build(); } } Modified: httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1747724&r1=1747723&r2=1747724&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java (original) +++ httpcomponents/httpclient/branches/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java Fri Jun 10 14:38:35 2016 @@ -170,10 +170,10 @@ class InternalHttpClient extends Closeab final HttpParams params = request.getParams(); if (params instanceof HttpParamsNames) { if (!((HttpParamsNames) params).getNames().isEmpty()) { - config = HttpClientParamConfig.getRequestConfig(params); + config = HttpClientParamConfig.getRequestConfig(params, this.defaultConfig); } } else { - config = HttpClientParamConfig.getRequestConfig(params); + config = HttpClientParamConfig.getRequestConfig(params, this.defaultConfig); } } if (config != null) {