Author: pmouawad
Date: Wed Oct 12 09:43:21 2016
New Revision: 1764422

URL: http://svn.apache.org/viewvc?rev=1764422&view=rev
Log:
Bug 53039 - HTTP Request : Be able to handle responses which size exceeds 
2147483647 bytes
Fix bug as per Felix Schumacher review, thx
Bugzilla Id: 53039

Modified:
    
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java
    
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/HTTPFileImpl.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java?rev=1764422&r1=1764421&r2=1764422&view=diff
==============================================================================
--- 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java
 (original)
+++ 
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java
 Wed Oct 12 09:43:21 2016
@@ -62,9 +62,15 @@ public class HTTPFileImpl extends HTTPAb
             byte[] readBuffer = new byte[bufferSize];
             int bytesReadInBuffer = 0;
             long totalBytes = 0;
+            boolean storeInBOS = true;
             while ((bytesReadInBuffer = is.read(readBuffer)) > -1) {
-                
if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) {
-                    bos.write(readBuffer, 0, bytesReadInBuffer);
+                if(storeInBOS) {
+                    
if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) {
+                        bos.write(readBuffer, 0, bytesReadInBuffer);
+                    } else {
+                        bos.write(readBuffer, 0, 
(int)(MAX_BYTES_TO_STORE_PER_REQUEST-totalBytes));
+                        storeInBOS = false;
+                    }
                 }
                 totalBytes += bytesReadInBuffer;
             }

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=1764422&r1=1764421&r2=1764422&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
 Wed Oct 12 09:43:21 2016
@@ -1791,6 +1791,7 @@ public abstract class HTTPSamplerBase ex
             int bytesReadInBuffer = 0;
             long totalBytes = 0;
             boolean first = true;
+            boolean storeInBOS = true;
             while ((bytesReadInBuffer = in.read(readBuffer)) > -1) {
                 if (first) {
                     sampleResult.latencyEnd();
@@ -1806,9 +1807,14 @@ public abstract class HTTPSamplerBase ex
                 }
                 
                 if (md == null) {
-                    
if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) {
-                        w.write(readBuffer, 0, bytesReadInBuffer);
-                    } 
+                    if(storeInBOS) {
+                        
if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) {
+                            w.write(readBuffer, 0, bytesReadInBuffer);
+                        } else {
+                            w.write(readBuffer, 0, 
(int)(MAX_BYTES_TO_STORE_PER_REQUEST-totalBytes));
+                            storeInBOS = false;
+                        }
+                    }
                 } else {
                     md.update(readBuffer, 0, bytesReadInBuffer);
                 }


Reply via email to