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/18 00:05:34 UTC

svn commit: r407387 - /jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java

Author: sebb
Date: Wed May 17 15:05:34 2006
New Revision: 407387

URL: http://svn.apache.org/viewvc?rev=407387&view=rev
Log:
Set Autoredirects correctly
Add cookie debug logs

Modified:
    jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java

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=407387&r1=407386&r2=407387&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 Wed May 17 15:05:34 2006
@@ -292,7 +292,7 @@
 //		}
 
 		// Allow HttpClient to handle the redirects:
-		httpMethod.setFollowRedirects(getFollowRedirects());
+		httpMethod.setFollowRedirects(getAutoRedirects());
 
 		// a well-behaved browser is supposed to send 'Connection: close'
 		// with the last request to an HTTP server. Instead, most browsers
@@ -391,17 +391,35 @@
                     continue;
                 long exp = cookie.getExpires();
                 long now = System.currentTimeMillis() / 1000 ;
-    			if ( host.endsWith(cookie.getDomain())
-                        && u.getFile().startsWith(cookie.getPath()) 
+    			String urlPath = u.getPath();
+                if (log.isDebugEnabled()){
+                    log.debug("Should we send cookie: "+cookie.toString());
+                    log.debug("Host="+host+" Path="+urlPath+" Now="+now);
+                }                
+                String cookiePath = cookie.getPath();
+                String cookieDomain = cookie.getDomain();
+                if ( host.endsWith(cookieDomain)
+                        && urlPath.startsWith(cookiePath) 
                         && (exp == 0 || exp > now)) {
-    				org.apache.commons.httpclient.Cookie newCookie
-                    = new org.apache.commons.httpclient.Cookie(cookie.getDomain(), cookie.getName(),
-    				     cookie.getValue(), cookie.getPath(), null, false);
+    				String cookieName = cookie.getName();
+                    String cookieValue = cookie.getValue();
+                    org.apache.commons.httpclient.Cookie newCookie
+                    = new org.apache.commons.httpclient.Cookie(cookieDomain, cookieName,
+    				     cookieValue, cookiePath, null, false);
     				state.addCookie(newCookie);
-    				cookieHeader.append(cookie.getName());
+    				cookieHeader.append(cookieName);
                     cookieHeader.append("="); // $NON-NLS-1$
-                    cookieHeader.append(cookie.getValue());
-    			}
+                    cookieHeader.append(cookieValue);
+                    if (log.isDebugEnabled()){
+                        log.debug("Matched cookie");
+                    }
+                    
+    			} else {
+                    if (log.isDebugEnabled()){
+                        log.debug("Did not match cookie.");
+                    }
+                    
+                }
     		}
         }
 		return cookieHeader.toString();
@@ -675,12 +693,13 @@
 			org.apache.commons.httpclient.Cookie [] c = client.getState().getCookies();
 			for (int i = 0; i < c.length; i++) {
 				Date exp = c[i].getExpiryDate();// might be absent
-				//System.out.println("Cookie[" + i + "]: " + c[i].getName() + " := " + c[i].getValue());
-
 				Cookie cookie = new Cookie(c[i].getName(), 
 					c[i].getValue(), c[i].getDomain(), c[i].getPath(), c[i].getSecure(), exp == null ? 0 : exp.getTime() / 1000);
 				
 				cookieManager.add( cookie );
+                if (log.isDebugEnabled()){
+                    log.debug("Saved Cookie: " + cookie.toString());
+                }
 			}
 		}
 	}



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org