You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/05/26 01:20:19 UTC
svn commit: r409504 - in /jakarta/jmeter/branches/rel-2-1:
src/protocol/http/org/apache/jmeter/protocol/http/sampler/ xdocs/
Author: sebb
Date: Thu May 25 16:20:18 2006
New Revision: 409504
URL: http://svn.apache.org/viewvc?rev=409504&view=rev
Log:
Bug 30267 - handle AutoRedirects properly
Modified:
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java?rev=409504&r1=409503&r2=409504&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler.java Thu May 25 16:20:18 2006
@@ -141,20 +141,6 @@
*/
protected HttpURLConnection setupConnection(URL u, String method, HTTPSampleResult res) throws IOException {
HttpURLConnection conn;
- // [Jordi <js...@atg.com>]
- // I've not been able to find out why we're not using this
- // feature of HttpURLConnections and we're doing redirection
- // by hand instead. Everything would be so much simpler...
- // [/Jordi]
- // Mike: answer - it didn't work. Maybe in JDK1.4 it works, but
- // honestly, it doesn't seem like they're working on this.
- // My longer term plan is to use Apache's home grown HTTP Client, or
- // maybe even HTTPUnit's classes. I'm sure both would be better than
- // Sun's.
-
- // [sebb] Make redirect following configurable (see bug 19004)
- // They do seem to work on JVM 1.4.1_03 (Sun/WinXP)
- HttpURLConnection.setFollowRedirects(getPropertyAsBoolean(AUTO_REDIRECTS));
SSLManager sslmgr = null;
if (PROTOCOL_HTTPS.equalsIgnoreCase(u.getProtocol())) {
@@ -166,6 +152,8 @@
}
conn = (HttpURLConnection) u.openConnection();
+ // Update follow redirects setting just for this connection
+ conn.setInstanceFollowRedirects(getAutoRedirects());
if (PROTOCOL_HTTPS.equalsIgnoreCase(u.getProtocol())) {
try {
@@ -475,6 +463,11 @@
res.setRedirectLocation(conn.getHeaderField("Location"));
}
+ // If we redirected automatically, the URL may have changed
+ if (getAutoRedirects()){
+ res.setURL(conn.getURL());
+ }
+
// Store any cookies received in the cookie manager:
saveConnectionCookies(conn, url, getCookieManager());
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java?rev=409504&r1=409503&r2=409504&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java Thu May 25 16:20:18 2006
@@ -633,6 +633,11 @@
res.setRedirectLocation(httpMethod.getResponseHeader("Location").getValue()); // $NON-NLS-1$
}
+ // If we redirected automatically, the URL may have changed
+ if (getAutoRedirects()){
+ res.setURL(new URL(httpMethod.getURI().toString()));
+ }
+
// Store any cookies received in the cookie manager:
saveConnectionCookies(client, getCookieManager());
Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java?rev=409504&r1=409503&r2=409504&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Thu May 25 16:20:18 2006
@@ -648,9 +648,8 @@
*
* @param res
* result of the initial request - must contain an HTML response
- * @param createContainerResult
- * whether to create a "container" or just use the provided
- * <code>res</code> for that purpose
+ * @param container
+ * for storing the results
* @param frameDepth
* Depth of this target in the frame structure. Used only to
* prevent infinite recursion.
Modified: jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml?rev=409504&r1=409503&r2=409504&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml (original)
+++ jakarta/jmeter/branches/rel-2-1/xdocs/changes.xml Thu May 25 16:20:18 2006
@@ -159,6 +159,7 @@
<li>Bug 39599 - ConcurrentModificationException</li>
<li>HTTPSampler2 now handles Auto and Follow redirects correctly</li>
<li>Bug 29481 - fix reloading sample results so subresults not counted twice</li>
+<li>Bug 30267 - handle AutoRedirects properly</li>
</ul>
<h4>Other changes</h4>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org