jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1415587 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java xdocs/changes.xml
Date Fri, 30 Nov 2012 11:16:09 GMT
Author: pmouawad
Date: Fri Nov 30 11:16:08 2012
New Revision: 1415587

URL: http://svn.apache.org/viewvc?rev=1415587&view=rev
Log:
Bug 54057 - Proxy option to set user and password at startup (-u and -a) not working with
HTTPClient 4
Bugzilla Id: 54057

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1415587&r1=1415586&r2=1415587&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
Fri Nov 30 11:16:08 2012
@@ -49,6 +49,7 @@ import org.apache.http.HttpResponseInter
 import org.apache.http.NameValuePair;
 import org.apache.http.StatusLine;
 import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
 import org.apache.http.auth.NTCredentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.HttpClient;
@@ -259,7 +260,7 @@ public class HTTPHC4Impl extends HTTPHCA
         }
 
         HttpContext localContext = new BasicHttpContext();
-
+        
         res.sampleStart();
 
         final CacheManager cacheManager = getCacheManager();
@@ -506,7 +507,8 @@ public class HTTPHC4Impl extends HTTPHCA
                 HttpHost proxy = new HttpHost(proxyHost, proxyPort);
                 clientParams.setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                 String proxyUser = getProxyUser();
-                if (proxyUser.length() > 0) {
+                
+                if (proxyUser.length() > 0) {                   
                     ((AbstractHttpClient) httpClient).getCredentialsProvider().setCredentials(
                             new AuthScope(proxyHost, proxyPort),
                             new NTCredentials(proxyUser, getProxyPass(), localHost, PROXY_DOMAIN));
@@ -537,7 +539,7 @@ public class HTTPHC4Impl extends HTTPHCA
 
         // TODO - should this be done when the client is created?
         // If so, then the details need to be added as part of HttpClientKey
-        setConnectionAuthorization(httpClient, url, getAuthManager());
+        setConnectionAuthorization(httpClient, url, getAuthManager(), key);
 
         return httpClient;
     }
@@ -715,7 +717,14 @@ public class HTTPHC4Impl extends HTTPHCA
         return hdrs.toString();
     }
 
-    private void setConnectionAuthorization(HttpClient client, URL url, AuthManager authManager)
{
+    /**
+     * Setup credentials for url AuthScope but keeps Proxy AuthScope credentials
+     * @param client HttpClient
+     * @param url URL
+     * @param authManager {@link AuthManager}
+     * @param key key
+     */
+    private void setConnectionAuthorization(HttpClient client, URL url, AuthManager authManager,
HttpClientKey key) {
         CredentialsProvider credentialsProvider = 
             ((AbstractHttpClient) client).getCredentialsProvider();
         if (authManager != null) {
@@ -734,7 +743,16 @@ public class HTTPHC4Impl extends HTTPHCA
                 credentialsProvider.clear();
             }
         } else {
-            credentialsProvider.clear();            
+            Credentials credentials = null;
+            AuthScope authScope = null;
+            if(key.hasProxy && !StringUtils.isEmpty(key.proxyUser)) {
+                authScope = new AuthScope(key.proxyHost, key.proxyPort);
+                credentials = credentialsProvider.getCredentials(authScope);
+            }
+            credentialsProvider.clear(); 
+            if(credentials != null) {
+                credentialsProvider.setCredentials(authScope, credentials);
+            }
         }
     }
 

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1415587&r1=1415586&r2=1415587&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Nov 30 11:16:08 2012
@@ -152,6 +152,7 @@ and right angle bracket (>) in search
 <li><bugzilla>54129</bugzilla> - Search Feature does not find text although
existing in elements </li>
 <li><bugzilla>54023</bugzilla> - Unable to start JMeter from a root directory
and if the full path of JMeter installation contains one or more spaces (Unix/linux)</li>
 <li><bugzilla>54172</bugzilla> - Duplicate shortcut key not working and
CTRL+C / CTRL+V / CTRL+V do not cancel default event</li>
+<li><bugzilla>54057</bugzilla> - Proxy option to set user and password
at startup (-u and -a) not working with HTTPClient 4</li>
 </ul>
 
 <!-- =================== Improvements =================== -->



Mime
View raw message