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 2008/05/03 22:18:23 UTC

svn commit: r653127 - /jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java

Author: sebb
Date: Sat May  3 13:18:23 2008
New Revision: 653127

URL: http://svn.apache.org/viewvc?rev=653127&view=rev
Log:
Minor tidyup

Modified:
    jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java

Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java?rev=653127&r1=653126&r2=653127&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/proxy/HttpRequestHdr.java Sat May  3 13:18:23 2008
@@ -80,9 +80,9 @@
 
     private byte[] rawPostData;
 
-	private Map headers = new HashMap();
+	private final Map headers = new HashMap();
 
-	private HTTPSamplerBase sampler;
+	private final HTTPSamplerBase sampler;
 
 	private HeaderManager headerManager;
 	
@@ -116,26 +116,30 @@
 		boolean inHeaders = true;
 		int readLength = 0;
 		int dataLength = 0;
-		boolean first = true;
+		boolean firstLine = true;
 		ByteArrayOutputStream clientRequest = new ByteArrayOutputStream();
 		ByteArrayOutputStream line = new ByteArrayOutputStream();
 		int x;
 		while ((inHeaders || readLength < dataLength) && ((x = in.read()) != -1)) {
 			line.write(x);
 			clientRequest.write(x);
-			if (first && !CharUtils.isAscii((char) x)){
+			if (firstLine && !CharUtils.isAscii((char) x)){// includes \n
 				throw new IllegalArgumentException("Only ASCII supported in headers (perhaps SSL was used?)");
 			}
 			if (inHeaders && (byte) x == (byte) '\n') { // $NON-NLS-1$
 				if (line.size() < 3) {
 					inHeaders = false;
-					first = false; // cannot be first line either
+					firstLine = false; // cannot be first line either
 				}
-				if (first) {
+				if (firstLine) {
 					parseFirstLine(line.toString());
-					first = false;
+					firstLine = false;
 				} else {
-					dataLength = Math.max(parseLine(line.toString()), dataLength);
+				    // parse other header lines, looking for Content-Length
+					final int contentLen = parseLine(line.toString());
+					if (contentLen > 0) {
+					    dataLength = contentLen; // Save the last valid content length one
+					}
 				}
                 if (log.isDebugEnabled()){
     				log.debug("Client Request Line: " + line.toString());



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