jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1578188 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/
Date Mon, 17 Mar 2014 00:46:21 GMT
Author: sebb
Date: Mon Mar 17 00:46:21 2014
New Revision: 1578188

URL: http://svn.apache.org/r1578188
Log:
Move redirect location processing from HC3/HC4 samplers to HTTPSamplerBase#followRedirects()
Bugzilla Id: 56231

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

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java?rev=1578188&r1=1578187&r2=1578188&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
Mon Mar 17 00:46:21 2014
@@ -69,7 +69,6 @@ import org.apache.jmeter.protocol.http.c
 import org.apache.jmeter.protocol.http.control.CacheManager;
 import org.apache.jmeter.protocol.http.control.CookieManager;
 import org.apache.jmeter.protocol.http.control.HeaderManager;
-import org.apache.jmeter.protocol.http.util.ConversionUtils;
 import org.apache.jmeter.protocol.http.util.EncoderCache;
 import org.apache.jmeter.protocol.http.util.HTTPArgument;
 import org.apache.jmeter.protocol.http.util.HTTPConstants;
@@ -95,8 +94,6 @@ public class HTTPHC3Impl extends HTTPHCA
     /** retry count to be used (default 1); 0 = disable retries */
     private static final int RETRY_COUNT = JMeterUtils.getPropDefault("httpclient3.retrycount",
0);
 
-    private static final boolean STRICT_RFC_2616 = JMeterUtils.getPropDefault("jmeter.httpclient.strict_rfc2616",
false);
-
     private static final String HTTP_AUTHENTICATION_PREEMPTIVE = "http.authentication.preemptive";
// $NON-NLS-1$
 
     private static final boolean canSetPreEmptive; // OK to set pre-emptive auth?
@@ -194,8 +191,10 @@ public class HTTPHC3Impl extends HTTPHCA
 
         String urlStr = url.toString();
 
-        log.debug("Start : sample " + urlStr);
-        log.debug("method " + method);
+        if (log.isDebugEnabled()) {
+            log.debug("Start : sample " + urlStr);
+            log.debug("method " + method+ " followingRedirect " + areFollowingRedirect +
" depth " + frameDepth);            
+        }
 
         HttpMethodBase httpMethod = null;
 
@@ -322,17 +321,8 @@ public class HTTPHC3Impl extends HTTPHCA
                 if (headerLocation == null) { // HTTP protocol violation, but avoids NPE
                     throw new IllegalArgumentException("Missing location header");
                 }
-                try {
-                    String redirectLocation = headerLocation.getValue();
-                    if(!STRICT_RFC_2616 && !(redirectLocation.startsWith("http://")||redirectLocation.startsWith("https://")))
{
-                        redirectLocation = ConversionUtils.buildFullUrlFromRelative(url,
redirectLocation);
-                    }
-                    res.setRedirectLocation(redirectLocation); // in case sanitising fails
-                    final URL redirectUrl = new URL(redirectLocation);
-                    res.setRedirectLocation(ConversionUtils.sanitizeUrl(redirectUrl).toString());
-                } catch (Exception e) {
-                    log.error("Error sanitizing URL:"+headerLocation.getValue()+", message:"+e.getMessage());
-                }
+                String redirectLocation = headerLocation.getValue();
+                res.setRedirectLocation(redirectLocation); // in case sanitising fails
             }
 
             // record some sizes to allow HTTPSampleResult.getBytes() with different options

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=1578188&r1=1578187&r2=1578188&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
Mon Mar 17 00:46:21 2014
@@ -104,7 +104,6 @@ import org.apache.jmeter.protocol.http.c
 import org.apache.jmeter.protocol.http.control.CacheManager;
 import org.apache.jmeter.protocol.http.control.CookieManager;
 import org.apache.jmeter.protocol.http.control.HeaderManager;
-import org.apache.jmeter.protocol.http.util.ConversionUtils;
 import org.apache.jmeter.protocol.http.util.EncoderCache;
 import org.apache.jmeter.protocol.http.util.HC4TrustAllSSLSocketFactory;
 import org.apache.jmeter.protocol.http.util.HTTPArgument;
@@ -129,8 +128,6 @@ public class HTTPHC4Impl extends HTTPHCA
 
     private static final Logger log = LoggingManager.getLoggerForClass();
 
-    private static final boolean STRICT_RFC_2616 = JMeterUtils.getPropDefault("jmeter.httpclient.strict_rfc2616",
false);
-
     /** retry count to be used (default 0); 0 = disable retries */
     private static final int RETRY_COUNT = JMeterUtils.getPropDefault("httpclient4.retrycount",
0);
 
@@ -267,6 +264,11 @@ public class HTTPHC4Impl extends HTTPHCA
     protected HTTPSampleResult sample(URL url, String method,
             boolean areFollowingRedirect, int frameDepth) {
 
+        if (log.isDebugEnabled()) {
+            log.debug("Start : sample " + url.toString());
+            log.debug("method " + method+ " followingRedirect " + areFollowingRedirect +
" depth " + frameDepth);            
+        }
+
         HTTPSampleResult res = createSampleResult(url, method);
 
         HttpClient httpClient = setupClient(url);
@@ -360,17 +362,7 @@ public class HTTPHC4Impl extends HTTPHCA
                     throw new IllegalArgumentException("Missing location header in redirect
for " + httpRequest.getRequestLine());
                 }
                 String redirectLocation = headerLocation.getValue();
-                if(!STRICT_RFC_2616 && !(redirectLocation.startsWith("http://")||
redirectLocation.startsWith("https://"))) {
-                    redirectLocation = ConversionUtils.buildFullUrlFromRelative(url, redirectLocation);
-                }
-                try {
-                    res.setRedirectLocation(redirectLocation); // in case sanitising fails
-                    final URL redirectUrl = new URL(redirectLocation);
-                    res.setRedirectLocation(ConversionUtils.sanitizeUrl(redirectUrl).toString());
-                } catch (Exception e) {
-                    log.error("Error in redirect URL for "  + httpRequest.getRequestLine()
-                            +"\n\tCould not sanitize URL: " + redirectLocation + "\n\t",
e);
-                }
+                res.setRedirectLocation(redirectLocation);
             }
 
             // record some sizes to allow HTTPSampleResult.getBytes() with different options

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=1578188&r1=1578187&r2=1578188&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Mon Mar 17 00:46:21 2014
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -1024,7 +1025,11 @@ public abstract class HTTPSamplerBase ex
      */
     public void parseArguments(String queryString, String contentEncoding) {
         String[] args = JOrphanUtils.split(queryString, QRY_SEP);
+        final boolean isDebug = log.isDebugEnabled();
         for (int i = 0; i < args.length; i++) {
+            if (isDebug) {
+                log.debug("Arg: " + args[i]);
+            }
             // need to handle four cases:
             // - string contains name=value
             // - string contains name=
@@ -1047,6 +1052,9 @@ public abstract class HTTPSamplerBase ex
                 value="";
             }
             if (name.length() > 0) {
+                if (isDebug) {
+                    log.debug("Name: " + name+ " Value: " + value+ " Metadata: " + metaData);
+                }
                 // If we know the encoding, we can decode the argument value,
                 // to make it easier to read for the user
                 if(!StringUtils.isEmpty(contentEncoding)) {
@@ -1414,7 +1422,8 @@ public abstract class HTTPSamplerBase ex
                 method = HTTPConstants.GET;
             }
             try {
-                final URL url = ConversionUtils.makeRelativeURL(lastRes.getURL(), location);
+                URL url = ConversionUtils.makeRelativeURL(lastRes.getURL(), location);
+                url = ConversionUtils.sanitizeUrl(url).toURL();
                 if (log.isDebugEnabled()) {
                     log.debug("Location as URL: " + url.toString());
                 }
@@ -1423,6 +1432,10 @@ public abstract class HTTPSamplerBase ex
                 errorResult(e, lastRes);
                 // The redirect URL we got was not a valid URL
                 invalidRedirectUrl = true;
+            } catch (URISyntaxException e) {
+                errorResult(e, lastRes);
+                // The redirect URL we got was not a valid URL
+                invalidRedirectUrl = true;
             }
             if (lastRes.getSubResults() != null && lastRes.getSubResults().length
> 0) {
                 SampleResult[] subs = lastRes.getSubResults();

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1578188&r1=1578187&r2=1578188&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Mon Mar 17 00:46:21 2014
@@ -126,6 +126,7 @@ A workaround is to use a Java 7 update 4
 <li><bugzilla>56178</bugzilla> - keytool error: Invalid escaped character
in AVA: - some characters must be escaped</li>
 <li><bugzilla>56222</bugzilla> - NPE if jmeter.httpclient.strict_rfc2616=true
and location is not absolute</li>
 <li><bugzilla>56263</bugzilla> - DefaultSamplerCreator should set BrowserCompatible
Multipart true</li>
+<li><bugzilla>56231</bugzilla> - Move redirect location processing from
HC3/HC4 samplers to HTTPSamplerBase#followRedirects()</li>
 </ul>
 
 <h3>Other Samplers</h3>



Mime
View raw message