Author: sebb
Date: Fri Jun 29 12:53:11 2007
New Revision: 552013

URL: http://svn.apache.org/viewvc?view=rev&rev=552013
Log:
Bug 42674 - default to pre-emptive authorisation if not specified

Modified:
    
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
    jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
    jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml

Modified: 
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?view=diff&rev=552013&r1=552012&r2=552013
==============================================================================
--- 
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
 (original)
+++ 
jakarta/jmeter/branches/rel-2-2/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
 Fri Jun 29 12:53:11 2007
@@ -90,6 +90,10 @@
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
+    private static final String HTTP_AUTHENTICATION_PREEMPTIVE = 
"http.authentication.preemptive"; // $NON-NLS-1$ 
+
+       private static boolean canSetPreEmptive; // OK to set pre-emptive auth?
+       
     static final String PROXY_HOST = 
         System.getProperty("http.proxyHost",""); // $NON-NLS-1$ 
 
@@ -204,6 +208,10 @@
             HttpClientDefaultParameters.load(file,params);
         }
         
+        // If the pre-emptive parameter is undefined, then we cans set it as 
needed
+        // otherwise we should do what the user requested.
+        canSetPreEmptive =  
params.getParameter(HTTP_AUTHENTICATION_PREEMPTIVE) == null;
+
         // Handle old-style JMeter properties
         // Default to HTTP version 1.1
         String ver=JMeterUtils.getPropDefault("httpclient.version","1.1"); // 
$NON-NLS-1$ $NON-NLS-2$
@@ -651,8 +659,8 @@
         * Extracts all the required authorization for that particular URL 
request
         * and sets it in the <code>HttpMethod</code> passed in.
         * 
-        * @param method
-        *            <code>HttpMethod</code> which represents the request
+        * @param client the HttpClient object
+        * 
         * @param u
         *            <code>URL</code> of the URL request
         * @param authManager
@@ -660,6 +668,7 @@
         *            this <code>UrlConfig</code>
         */
        void setConnectionAuthorization(HttpClient client, URL u, AuthManager 
authManager) {
+               HttpParams params = client.getParams();
                if (authManager != null) {
             Authorization auth = authManager.getAuthForURL(u);
             if (auth != null) {
@@ -680,10 +689,18 @@
                                     localHost,
                                                                        domain
                                                        ));
+                                       // We have credentials - should we set 
pre-emptive authentication?
+                                       if (canSetPreEmptive){
+                                               log.debug("Setting Pre-emptive 
authentication");
+                                               
params.setBooleanParameter(HTTP_AUTHENTICATION_PREEMPTIVE, true);
+                                       }
                        }
             else
             {
                 client.getState().clearCredentials();
+                if (canSetPreEmptive){
+                       
params.setBooleanParameter(HTTP_AUTHENTICATION_PREEMPTIVE, false);
+                }
             }
                }
         else

Modified: jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml?view=diff&rev=552013&r1=552012&r2=552013
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/changes.xml Fri Jun 29 12:53:11 2007
@@ -102,6 +102,17 @@
 https.sessioncontext.shared=true
 </pre>
 </p>
+<p>
+HttpClient now uses pre-emptive authentication. 
+This can be changed by setting the following:
+<pre>
+jmeter.properties:
+httpclient.parameters.file=httpclient.parameters
+
+httpclient.parameters:
+http.authentication.preemptive$Boolean=false
+</pre>
+</p>
 <h4>Incompatible changes (development):</h4>
 <p>
 <b>N.B.</b>The clear() method was defined in the following interfaces: 
Clearable, JMeterGUIComponent and TestElement.
@@ -168,6 +179,7 @@
 <li>BeanShell elements now support ThreadListener and TestListener 
interfaces</li>
 <li>Bug 42582 - JSON pretty printing in Tree View Listener</li>
 <li>Http Autoredirects are now enabled by default when creating new 
samplers</li>
+<li>Bug 42674 - default to pre-emptive authorisation if not specified</li>
 </ul>
 
 <h4>Non-functional improvements:</h4>

Modified: 
jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml?view=diff&rev=552013&r1=552012&r2=552013
==============================================================================
--- jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml 
(original)
+++ jakarta/jmeter/branches/rel-2-2/xdocs/usermanual/component_reference.xml 
Fri Jun 29 12:53:11 2007
@@ -1927,16 +1927,15 @@
 your browser to access a restricted page, and your browser displays a login 
dialog box.  JMeter
 transmits the login information when it encounters this type of page.</p>
 <p>
-Some servers don't send a WWW-Authenticate response if the request requires 
authentication; 
-the request is just rejected, e.g. with response code 401.
-In such cases pre-emptive authentication needs to be enabled.
-To enable pre-emptive authentication, change the files below to add:
+In versions of JMeter after 2.2, the HttpClient sampler defaults to 
pre-emptive authentication
+if the setting has not been defined. To disable this, set the values as below, 
in which case
+authentication will only be performed in response to a challenge.
 <pre>
 jmeter.properties:
 httpclient.parameters.file=httpclient.parameters
 
 httpclient.parameters:
-http.authentication.preemptive$Boolean=true
+http.authentication.preemptive$Boolean=false
 </pre>
 Note: the above settings only apply to the HttpClient sampler (and the SOAP 
samplers, which use Httpclient).
 </p>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to