Author: pmouawad
Date: Fri Mar 18 20:17:05 2016
New Revision: 1735672
URL: http://svn.apache.org/viewvc?rev=1735672&view=rev
Log:
Isolate and document behaviour in case of redirect
Modified:
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
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=1735672&r1=1735671&r2=1735672&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
Fri Mar 18 20:17:05 2016
@@ -1501,9 +1501,8 @@ public abstract class HTTPSamplerBase ex
}
// Change all but HEAD into GET (Bug 55450)
String method = lastRes.getHTTPMethod();
- if (!HTTPConstants.HEAD.equalsIgnoreCase(method)) {
- method = HTTPConstants.GET;
- }
+ method = computeMethodForRedirect(method, res.getResponseCode());
+
try {
URL url = ConversionUtils.makeRelativeURL(lastRes.getURL(),
location);
url = ConversionUtils.sanitizeUrl(url).toURL();
@@ -1568,6 +1567,21 @@ public abstract class HTTPSamplerBase ex
}
/**
+ * See <a
href="http://tools.ietf.org/html/rfc2616#section-10.3">RFC2616#section-10.3</a>
+ * JMeter conforms currently to HttpClient 4.5.2 supported RFC
+ * TODO Update when migrating to HttpClient 5.X
+ * @param initialMethod the initial HTTP Method
+ * @param responseCode String response code
+ * @return the new HTTP Method as per RFC
+ */
+ private String computeMethodForRedirect(String initialMethod, String
responseCode) {
+ if (!HTTPConstants.HEAD.equalsIgnoreCase(initialMethod)) {
+ return HTTPConstants.GET;
+ }
+ return initialMethod;
+ }
+
+ /**
* Follow redirects and download page resources if appropriate. this works,
* but the container stuff here is what's doing it. followRedirects() is
* actually doing the work to make sure we have only one container to make