ASF Bugzilla – Attachment 34355 Details for
Bug 53039
HTTP Request : Be able to handle responses which size exceeds 2147483647 bytes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Last version after fix to Bug 60229
BUG_53039.patch (text/plain), 33.40 KB, created by
Philippe Mouawad
on 2016-10-10 20:04:56 UTC
(
hide
)
Description:
Last version after fix to Bug 60229
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2016-10-10 20:04:56 UTC
Size:
33.40 KB
patch
obsolete
>Index: src/components/org/apache/jmeter/assertions/SMIMEAssertion.java >=================================================================== >--- src/components/org/apache/jmeter/assertions/SMIMEAssertion.java (revision 1763872) >+++ src/components/org/apache/jmeter/assertions/SMIMEAssertion.java (working copy) >@@ -302,7 +302,7 @@ > > final SampleResult sampleResult = subResults[messageNumber]; > if (log.isDebugEnabled()) { >- log.debug("Bytes: "+sampleResult.getBytes()+" CT: "+sampleResult.getContentType()); >+ log.debug("Bytes: "+sampleResult.getBytesAsLong()+" CT: "+sampleResult.getContentType()); > } > byte[] data = sampleResult.getResponseData(); > Session session = Session.getDefaultInstance(new Properties()); >Index: src/components/org/apache/jmeter/assertions/SizeAssertion.java >=================================================================== >--- src/components/org/apache/jmeter/assertions/SizeAssertion.java (revision 1763872) >+++ src/components/org/apache/jmeter/assertions/SizeAssertion.java (working copy) >@@ -79,7 +79,7 @@ > String variableName = getVariableName(); > String value = getThreadContext().getVariables().get(variableName); > try { >- resultSize = Integer.parseInt(value); >+ resultSize = Long.parseLong(value); > } catch (NumberFormatException e) { > result.setFailure(true); > result.setFailureMessage("Error parsing variable name: "+variableName+" value: "+value); >@@ -88,13 +88,13 @@ > } else if (isTestFieldResponseHeaders()) { > resultSize = response.getHeadersSize(); > } else if (isTestFieldResponseBody()) { >- resultSize = response.getBodySize(); >+ resultSize = response.getBodySizeAsLong(); > } else if (isTestFieldResponseCode()) { > resultSize = response.getResponseCode().length(); > } else if (isTestFieldResponseMessage()) { > resultSize = response.getResponseMessage().length(); > } else { >- resultSize = response.getBytes(); >+ resultSize = response.getBytesAsLong(); > } > // is the Sample the correct size? > final String msg = compareSize(resultSize); >Index: src/components/org/apache/jmeter/visualizers/SamplerResultTab.java >=================================================================== >--- src/components/org/apache/jmeter/visualizers/SamplerResultTab.java (revision 1764166) >+++ src/components/org/apache/jmeter/visualizers/SamplerResultTab.java (working copy) >@@ -238,10 +238,11 @@ > statsBuff.append(JMeterUtils.getResString("view_results_load_time")).append(sampleResult.getTime()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_connect_time")).append(sampleResult.getConnectTime()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_latency")).append(sampleResult.getLatency()).append(NL); //$NON-NLS-1$ >- statsBuff.append(JMeterUtils.getResString("view_results_size_in_bytes")).append(sampleResult.getBytes()).append(NL); //$NON-NLS-1$ >+ statsBuff.append(JMeterUtils.getResString("view_results_size_in_bytes")).append(sampleResult.getBytesAsLong()).append(NL); //$NON-NLS-1$ >+ statsBuff.append(JMeterUtils.getResString("view_results_sent_bytes")).append(sampleResult.getSentBytes()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_sent_bytes")).append(sampleResult.getSentBytes()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_size_headers_in_bytes")).append(sampleResult.getHeadersSize()).append(NL); //$NON-NLS-1$ >- statsBuff.append(JMeterUtils.getResString("view_results_size_body_in_bytes")).append(sampleResult.getBodySize()).append(NL); //$NON-NLS-1$ >+ statsBuff.append(JMeterUtils.getResString("view_results_size_body_in_bytes")).append(sampleResult.getBodySizeAsLong()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_sample_count")).append(sampleResult.getSampleCount()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_error_count")).append(sampleResult.getErrorCount()).append(NL); //$NON-NLS-1$ > statsBuff.append(JMeterUtils.getResString("view_results_datatype")).append(sampleResult.getDataType()).append(NL); //$NON-NLS-1$ >@@ -298,10 +299,10 @@ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_load_time"), sampleResult.getTime())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_connect_time"), sampleResult.getConnectTime())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_latency"), sampleResult.getLatency())); //$NON-NLS-1$ >- resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_in_bytes"), sampleResult.getBytes())); //$NON-NLS-1$ >+ resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_in_bytes"), sampleResult.getBytesAsLong())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_sent_bytes"),sampleResult.getSentBytes())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_headers_in_bytes"), sampleResult.getHeadersSize())); //$NON-NLS-1$ >- resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_body_in_bytes"), sampleResult.getBodySize())); //$NON-NLS-1$ >+ resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_size_body_in_bytes"), sampleResult.getBodySizeAsLong())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_sample_count"), sampleResult.getSampleCount())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_error_count"), sampleResult.getErrorCount())); //$NON-NLS-1$ > resultModel.addRow(new RowResult(JMeterUtils.getParsedLabel("view_results_response_code"), responseCode)); //$NON-NLS-1$ >Index: src/components/org/apache/jmeter/visualizers/TableVisualizer.java >=================================================================== >--- src/components/org/apache/jmeter/visualizers/TableVisualizer.java (revision 1764166) >+++ src/components/org/apache/jmeter/visualizers/TableVisualizer.java (working copy) >@@ -194,7 +194,7 @@ > res.getSampleLabel(), > res.getTime(), > res.isSuccessful(), >- res.getBytes(), >+ res.getBytesAsLong(), > res.getSentBytes(), > res.getLatency(), > res.getConnectTime() >Index: src/core/org/apache/jmeter/control/TransactionController.java >=================================================================== >--- src/core/org/apache/jmeter/control/TransactionController.java (revision 1764166) >+++ src/core/org/apache/jmeter/control/TransactionController.java (working copy) >@@ -321,7 +321,7 @@ > if(res != null && !se.isTransactionSampleEvent()) { > SampleResult sampleResult = se.getResult(); > res.setThreadName(sampleResult.getThreadName()); >- res.setBytes(res.getBytes() + sampleResult.getBytes()); >+ res.setBytes(res.getBytesAsLong() + sampleResult.getBytesAsLong()); > res.setSentBytes(res.getSentBytes() + sampleResult.getSentBytes()); > if (!isIncludeTimers()) {// Accumulate waiting time for later > pauseTime += sampleResult.getEndTime() - sampleResult.getTime() - prevEndTime; >Index: src/core/org/apache/jmeter/report/core/Sample.java >=================================================================== >--- src/core/org/apache/jmeter/report/core/Sample.java (revision 1763984) >+++ src/core/org/apache/jmeter/report/core/Sample.java (working copy) >@@ -260,8 +260,8 @@ > * > * @return the number of received bytes stored in the sample > */ >- public int getReceivedBytes() { >- return getData(int.class, CSVSaveService.CSV_BYTES).intValue(); >+ public long getReceivedBytes() { >+ return getData(long.class, CSVSaveService.CSV_BYTES).longValue(); > } > > /** >Index: src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java >=================================================================== >--- src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java (revision 1764166) >+++ src/core/org/apache/jmeter/samplers/DataStrippingSampleSender.java (working copy) >@@ -117,7 +117,7 @@ > * @param result {@link SampleResult} > */ > private void stripResponse(SampleResult result) { >- result.setBytes(result.getBytes()); >+ result.setBytes(result.getBytesAsLong()); > result.setResponseData(SampleResult.EMPTY_BA); > } > >Index: src/core/org/apache/jmeter/samplers/SampleResult.java >=================================================================== >--- src/core/org/apache/jmeter/samplers/SampleResult.java (revision 1764166) >+++ src/core/org/apache/jmeter/samplers/SampleResult.java (working copy) >@@ -210,11 +210,11 @@ > > private int sampleCount = 1; > >- private int bytes = 0; // Allows override of sample size in case sampler does not want to store all the data >+ private long bytes = 0; // Allows override of sample size in case sampler does not want to store all the data > > private int headersSize = 0; > >- private int bodySize = 0; >+ private long bodySize = 0; > > /** Currently active threads in this thread group */ > private volatile int groupThreads = 0; >@@ -267,7 +267,7 @@ > * Cache for responseData as string to avoid multiple computations > */ > private volatile transient String responseDataAsString; >- >+ > private long sentBytes; > > private long initOffset(){ >@@ -613,10 +613,10 @@ > // Extend the time to the end of the added sample > setEndTime(Math.max(getEndTime(), subResult.getEndTime() + nanoTimeOffset - subResult.nanoTimeOffset)); // Bug 51855 > // Include the byte count for the added sample >- setBytes(getBytes() + subResult.getBytes()); >+ setBytes(getBytesAsLong() + subResult.getBytesAsLong()); > setSentBytes(getSentBytes() + subResult.getSentBytes()); > setHeadersSize(getHeadersSize() + subResult.getHeadersSize()); >- setBodySize(getBodySize() + subResult.getBodySize()); >+ setBodySize(getBodySizeAsLong() + subResult.getBodySizeAsLong()); > addRawSubResult(subResult); > } > >@@ -1194,10 +1194,24 @@ > * @param length > * the number of bytes of the response data for this sample > */ >- public void setBytes(int length) { >+ public void setBytes(long length) { > bytes = length; > } >- >+ >+ /** >+ * In the event the sampler does want to pass back the actual contents, we >+ * still want to calculate the throughput. The bytes are the bytes of the >+ * response data. >+ * >+ * @param length >+ * the number of bytes of the response data for this sample >+ * @deprecated use setBytes(long) >+ */ >+ @Deprecated >+ public void setBytes(int length) { >+ setBytes((long) length); >+ } >+ > /** > * > * @param sentBytesCount long sent bytes >@@ -1217,15 +1231,26 @@ > * return the bytes returned by the response. > * > * @return byte count >+ * @deprecated use getBytesAsLong > */ >+ @Deprecated > public int getBytes() { >+ return (int) getBytesAsLong(); >+ } >+ >+ /** >+ * return the bytes returned by the response. >+ * >+ * @return byte count >+ */ >+ public long getBytesAsLong() { > if (GETBYTES_NETWORK_SIZE) { >- int tmpSum = this.getHeadersSize() + this.getBodySize(); >+ long tmpSum = this.getHeadersSize() + this.getBodySizeAsLong(); > return tmpSum == 0 ? bytes : tmpSum; > } else if (GETBYTES_HEADERS_SIZE) { > return this.getHeadersSize(); > } else if (GETBYTES_BODY_REALSIZE) { >- return this.getBodySize(); >+ return this.getBodySizeAsLong(); > } > return bytes == 0 ? responseData.length : bytes; > } >@@ -1383,14 +1408,22 @@ > /** > * @return the body size in bytes > */ >+ @Deprecated > public int getBodySize() { >+ return (int) getBodySizeAsLong(); >+ } >+ >+ /** >+ * @return the body size in bytes >+ */ >+ public long getBodySizeAsLong() { > return bodySize == 0 ? responseData.length : bodySize; > } > > /** > * @param bodySize the body size to set > */ >- public void setBodySize(int bodySize) { >+ public void setBodySize(long bodySize) { > this.bodySize = bodySize; > } > >Index: src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java >=================================================================== >--- src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java (revision 1764166) >+++ src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java (working copy) >@@ -72,7 +72,7 @@ > // Add Sample Counter > setSampleCount(getSampleCount() + res.getSampleCount()); > >- setBytes(getBytes() + res.getBytes()); >+ setBytes(getBytesAsLong() + res.getBytesAsLong()); > setSentBytes(getSentBytes() + res.getSentBytes()); > > // Add Error Counter >Index: src/core/org/apache/jmeter/save/CSVSaveService.java >=================================================================== >--- src/core/org/apache/jmeter/save/CSVSaveService.java (revision 1763984) >+++ src/core/org/apache/jmeter/save/CSVSaveService.java (working copy) >@@ -299,9 +299,9 @@ > if (saveConfig.saveBytes()) { > field = CSV_BYTES; > text = parts[i++]; >- result.setBytes(Integer.parseInt(text)); >+ result.setBytes(Long.parseLong(text)); > } >- >+ > if (saveConfig.saveSentBytes()) { > field = CSV_SENT_BYTES; > text = parts[i++]; >@@ -453,7 +453,7 @@ > text.append(CSV_BYTES); > text.append(delim); > } >- >+ > if (saveConfig.saveSentBytes()) { > text.append(CSV_SENT_BYTES); > text.append(delim); >@@ -936,9 +936,9 @@ > } > > if (saveConfig.saveBytes()) { >- text.append(sample.getBytes()); >+ text.append(sample.getBytesAsLong()); > } >- >+ > if (saveConfig.saveSentBytes()) { > text.append(sample.getSentBytes()); > } >Index: src/core/org/apache/jmeter/save/converters/SampleResultConverter.java >=================================================================== >--- src/core/org/apache/jmeter/save/converters/SampleResultConverter.java (revision 1764166) >+++ src/core/org/apache/jmeter/save/converters/SampleResultConverter.java (working copy) >@@ -320,7 +320,7 @@ > writer.addAttribute(ATT_DATA_ENCODING, ConversionHelp.encode(res.getDataEncodingNoDefault())); > } > if (save.saveBytes()) { >- writer.addAttribute(ATT_BYTES, String.valueOf(res.getBytes())); >+ writer.addAttribute(ATT_BYTES, String.valueOf(res.getBytesAsLong())); > } > if (save.saveSentBytes()) { > writer.addAttribute(ATT_SENT_BYTES, String.valueOf(res.getSentBytes())); >@@ -449,7 +449,7 @@ > res.setIdleTime(Converter.getLong(reader.getAttribute(ATT_IDLETIME))); > res.setLatency(Converter.getLong(reader.getAttribute(ATT_LATENCY))); > res.setConnectTime(Converter.getLong(reader.getAttribute(ATT_CONNECT_TIME))); >- res.setBytes(Converter.getInt(reader.getAttribute(ATT_BYTES))); >+ res.setBytes(Converter.getLong(reader.getAttribute(ATT_BYTES))); > res.setSentBytes(Converter.getLong(reader.getAttribute(ATT_SENT_BYTES))); > res.setSampleCount(Converter.getInt(reader.getAttribute(ATT_SAMPLE_COUNT),1)); // default is 1 > res.setErrorCount(Converter.getInt(reader.getAttribute(ATT_ERROR_COUNT),0)); // default is 0 >@@ -461,7 +461,7 @@ > File in = new File(resultFileName); > try (FileInputStream fis = new FileInputStream(in); > BufferedInputStream bis = new BufferedInputStream(fis)){ >- ByteArrayOutputStream outstream = new ByteArrayOutputStream(res.getBytes()); >+ ByteArrayOutputStream outstream = new ByteArrayOutputStream(4096); > byte[] buffer = new byte[4096]; > int len; > while ((len = bis.read(buffer)) > 0) { >@@ -474,7 +474,6 @@ > } > } > >- > /** > * @param arg0 the mapper > */ >Index: src/core/org/apache/jmeter/util/Calculator.java >=================================================================== >--- src/core/org/apache/jmeter/util/Calculator.java (revision 1763872) >+++ src/core/org/apache/jmeter/util/Calculator.java (working copy) >@@ -110,7 +110,7 @@ > * @param res the sample result; might represent multiple values > */ > public void addSample(SampleResult res) { >- addBytes(res.getBytes()); >+ addBytes(res.getBytesAsLong()); > addValue(res.getTime(),res.getSampleCount()); > errors+=res.getErrorCount(); // account for multiple samples > if (startTime == 0){ // not yet intialised >Index: src/core/org/apache/jmeter/visualizers/SamplingStatCalculator.java >=================================================================== >--- src/core/org/apache/jmeter/visualizers/SamplingStatCalculator.java (revision 1764166) >+++ src/core/org/apache/jmeter/visualizers/SamplingStatCalculator.java (working copy) >@@ -157,7 +157,7 @@ > boolean rbool; > synchronized (calculator) { > calculator.addValue(res.getTime(), res.getSampleCount()); >- calculator.addBytes(res.getBytes()); >+ calculator.addBytes(res.getBytesAsLong()); > setStartTime(res); > eCount = getCurrentSample().getErrorCount(); > eCount += res.getErrorCount(); >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java (revision 1763872) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java (working copy) >@@ -409,6 +409,32 @@ > */ > protected byte[] readResponse(SampleResult res, InputStream instream, > int responseContentLength) throws IOException { >+ return readResponse(res, instream, (long)responseContentLength); >+ } >+ /** >+ * Read response from the input stream, converting to MD5 digest if the >+ * useMD5 property is set. >+ * <p> >+ * For the MD5 case, the result byte count is set to the size of the >+ * original response. >+ * <p> >+ * Closes the inputStream >+ * <p> >+ * Invokes >+ * {@link HTTPSamplerBase#readResponse(SampleResult, InputStream, int)} >+ * >+ * @param res >+ * sample to store information about the response into >+ * @param instream >+ * input stream from which to read the response >+ * @param responseContentLength >+ * expected input length or zero >+ * @return the response or the MD5 of the response >+ * @throws IOException >+ * if reading the result fails >+ */ >+ protected byte[] readResponse(SampleResult res, InputStream instream, >+ long responseContentLength) throws IOException { > return testElement.readResponse(res, instream, responseContentLength); > } > >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java (revision 1763872) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPFileImpl.java (working copy) >@@ -26,11 +26,14 @@ > > import org.apache.commons.io.IOUtils; > import org.apache.jmeter.protocol.http.util.HTTPConstants; >+import org.apache.jmeter.util.JMeterUtils; > > /** > * HTTP Sampler which can read from file: URLs > */ > public class HTTPFileImpl extends HTTPAbstractImpl { >+ private static final int MAX_BYTES_TO_STORE_PER_REQUEST = >+ JMeterUtils.getPropDefault("httpsampler.max_bytes_to_store_per_request", 10 * 1024 *1024); // $NON-NLS-1$ // default value: false > > protected HTTPFileImpl(HTTPSamplerBase base) { > super(base); >@@ -51,13 +54,24 @@ > res.setSampleLabel(url.toString()); > InputStream is = null; > res.sampleStart(); >- try { >+ int bufferSize = 4096; >+ try ( org.apache.commons.io.output.ByteArrayOutputStream bos = new org.apache.commons.io.output.ByteArrayOutputStream(bufferSize) ) { > byte[] responseData; > URLConnection conn = url.openConnection(); > is = conn.getInputStream(); >- responseData = IOUtils.toByteArray(is); >+ byte[] readBuffer = new byte[bufferSize]; >+ int bytesReadInBuffer = 0; >+ long totalBytes = 0; >+ while ((bytesReadInBuffer = is.read(readBuffer)) > -1) { >+ if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) { >+ bos.write(readBuffer, 0, bytesReadInBuffer); >+ } >+ totalBytes += bytesReadInBuffer; >+ } >+ responseData = bos.toByteArray(); > res.sampleEnd(); > res.setResponseData(responseData); >+ res.setBodySize(totalBytes); > res.setResponseCodeOK(); > res.setResponseMessageOK(); > res.setSuccessful(true); >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (revision 1763872) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java (working copy) >@@ -285,9 +285,9 @@ > Header responseHeader = httpMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_ENCODING); > if (responseHeader!= null && HTTPConstants.ENCODING_GZIP.equals(responseHeader.getValue())) { > InputStream tmpInput = new GZIPInputStream(instream); // tmp inputstream needs to have a good counting >- res.setResponseData(readResponse(res, tmpInput, (int) httpMethod.getResponseContentLength())); >+ res.setResponseData(readResponse(res, tmpInput, httpMethod.getResponseContentLength())); > } else { >- res.setResponseData(readResponse(res, instream, (int) httpMethod.getResponseContentLength())); >+ res.setResponseData(readResponse(res, instream, httpMethod.getResponseContentLength())); > } > } finally { > JOrphanUtils.closeQuietly(instream); >@@ -328,12 +328,12 @@ > > // record some sizes to allow HTTPSampleResult.getBytes() with different options > if (instream != null) { >- res.setBodySize(((CountingInputStream) instream).getCount()); >+ res.setBodySize(((CountingInputStream) instream).getByteCount()); > } > res.setHeadersSize(calculateHeadersSize(httpMethod)); > if (log.isDebugEnabled()) { >- log.debug("Response headersSize=" + res.getHeadersSize() + " bodySize=" + res.getBodySize() >- + " Total=" + (res.getHeadersSize() + res.getBodySize())); >+ log.debug("Response headersSize=" + res.getHeadersSize() + " bodySize=" + res.getBodySizeAsLong() >+ + " Total=" + (res.getHeadersSize() + res.getBodySizeAsLong())); > } > > // If we redirected automatically, the URL may have changed >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (revision 1763984) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (working copy) >@@ -406,7 +406,7 @@ > } > HttpEntity entity = httpResponse.getEntity(); > if (entity != null) { >- res.setResponseData(readResponse(res, entity.getContent(), (int) entity.getContentLength())); >+ res.setResponseData(readResponse(res, entity.getContent(), entity.getContentLength())); > } > > res.sampleEnd(); // Done with the sampling proper. >@@ -437,12 +437,12 @@ > + 1 // Add \r for initial header > + 2; // final \r\n before data > long totalBytes = metrics.getReceivedBytesCount(); >- res.setHeadersSize((int) headerBytes); >- res.setBodySize((int)(totalBytes - headerBytes)); >+ res.setHeadersSize((int)headerBytes); >+ res.setBodySize(totalBytes - headerBytes); > res.setSentBytes(metrics.getSentBytesCount()); > if (log.isDebugEnabled()) { >- log.debug("ResponseHeadersSize=" + res.getHeadersSize() + " Content-Length=" + res.getBodySize() >- + " Total=" + (res.getHeadersSize() + res.getBodySize())); >+ log.debug("ResponseHeadersSize=" + res.getHeadersSize() + " Content-Length=" + res.getBodySizeAsLong() >+ + " Total=" + (res.getHeadersSize() + res.getBodySizeAsLong())); > } > > // If we redirected automatically, the URL may have changed >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java (revision 1763872) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java (working copy) >@@ -284,7 +284,7 @@ > // N.B. this closes 'in' > byte[] responseData = readResponse(res, in, contentLength); > if (instream != null) { >- res.setBodySize(((CountingInputStream) instream).getCount()); >+ res.setBodySize(((CountingInputStream) instream).getByteCount()); > instream.close(); > } > return responseData; >@@ -566,8 +566,8 @@ > res.setHeadersSize(responseHeaders.replaceAll("\n", "\r\n") // $NON-NLS-1$ $NON-NLS-2$ > .length() + 2); // add 2 for a '\r\n' at end of headers (before data) > if (log.isDebugEnabled()) { >- log.debug("Response headersSize=" + res.getHeadersSize() + " bodySize=" + res.getBodySize() >- + " Total=" + (res.getHeadersSize() + res.getBodySize())); >+ log.debug("Response headersSize=" + res.getHeadersSize() + " bodySize=" + res.getBodySizeAsLong() >+ + " Total=" + (res.getHeadersSize() + res.getBodySizeAsLong())); > } > > // If we redirected automatically, the URL may have changed >Index: src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java >=================================================================== >--- src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (revision 1763872) >+++ src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java (working copy) >@@ -189,6 +189,12 @@ > > public static final boolean BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT = false; // The default setting to be used (i.e. historic) > >+ private static final int MAX_BYTES_TO_STORE_PER_REQUEST = >+ JMeterUtils.getPropDefault("httpsampler.max_bytes_to_store_per_request", 10 * 1024 *1024); // $NON-NLS-1$ // default value: false >+ >+ private static final int MAX_BUFFER_SIZE = >+ JMeterUtils.getPropDefault("httpsampler.max_buffer_size", 65 * 1024); // $NON-NLS-1$ >+ > private static final boolean IGNORE_FAILED_EMBEDDED_RESOURCES = > JMeterUtils.getPropDefault("httpsampler.ignore_failed_embedded_resources", false); // $NON-NLS-1$ // default value: false > >@@ -926,6 +932,7 @@ > private static final boolean SEPARATE_CONTAINER = > JMeterUtils.getPropDefault("httpsampler.separate.container", true); // $NON-NLS-1$ > >+ > /** > * Get the URL, built from its component parts. > * >@@ -1757,7 +1764,7 @@ > * @return the response or the MD5 of the response > * @throws IOException if reading the result fails > */ >- public byte[] readResponse(SampleResult sampleResult, InputStream in, int length) throws IOException { >+ public byte[] readResponse(SampleResult sampleResult, InputStream in, long length) throws IOException { > > OutputStream w = null; > try { >@@ -1776,34 +1783,36 @@ > if (!knownResponseLength) { > bufferSize = 4 * 1024; > } else { >- bufferSize = length; >+ bufferSize = (int) Math.min(MAX_BUFFER_SIZE, length); > } > } > > >- int bytesRead = 0; >- int totalBytes = 0; >+ int bytesReadInBuffer = 0; >+ long totalBytes = 0; > boolean first = true; >- while ((bytesRead = in.read(readBuffer)) > -1) { >+ while ((bytesReadInBuffer = in.read(readBuffer)) > -1) { > if (first) { > sampleResult.latencyEnd(); > first = false; > if(md == null) { >- if(knownResponseLength) { >- w = new DirectAccessByteArrayOutputStream(bufferSize); >+ if(!knownResponseLength) { >+ w = new org.apache.commons.io.output.ByteArrayOutputStream(bufferSize); > } > else { >- w = new org.apache.commons.io.output.ByteArrayOutputStream(bufferSize); >+ w = new DirectAccessByteArrayOutputStream(bufferSize); > } > } > } > > if (md == null) { >- w.write(readBuffer, 0, bytesRead); >+ if(totalBytes+bytesReadInBuffer<=MAX_BYTES_TO_STORE_PER_REQUEST) { >+ w.write(readBuffer, 0, bytesReadInBuffer); >+ } > } else { >- md.update(readBuffer, 0, bytesRead); >- totalBytes += bytesRead; >+ md.update(readBuffer, 0, bytesReadInBuffer); > } >+ totalBytes += bytesReadInBuffer; > } > > if (first) { // Bug 46838 - if there was no data, still need to set latency >@@ -1811,13 +1820,14 @@ > return new byte[0]; > } > >- if (md != null) { >+ if (md == null) { >+ return toByteArray(w); >+ } else { > byte[] md5Result = md.digest(); > sampleResult.setBytes(totalBytes); >- return JOrphanUtils.baToHexBytes(md5Result); >+ return JOrphanUtils.baToHexBytes(md5Result); > } > >- return toByteArray(w); > } finally { > IOUtils.closeQuietly(in); > IOUtils.closeQuietly(w); >Index: test/src/org/apache/jmeter/samplers/TestSampleResult.java >=================================================================== >--- test/src/org/apache/jmeter/samplers/TestSampleResult.java (revision 1763872) >+++ test/src/org/apache/jmeter/samplers/TestSampleResult.java (working copy) >@@ -146,7 +146,7 @@ > res.setBytes(100); > res.setSampleLabel("sample of size 100 bytes"); > res.sampleEnd(); >- assertEquals(100, res.getBytes()); >+ assertEquals(100, res.getBytesAsLong()); > assertEquals("sample of size 100 bytes", res.getSampleLabel()); > } > >@@ -234,7 +234,7 @@ > long child1Elapsed = child1.getTime(); > > assertTrue(child1.isSuccessful()); >- assertEquals(100, child1.getBytes()); >+ assertEquals(100, child1.getBytesAsLong()); > assertEquals("Child1 Sample", child1.getSampleLabel()); > assertEquals(1, child1.getSampleCount()); > assertEquals(0, child1.getSubResults().length); >@@ -257,7 +257,7 @@ > long child2Elapsed = child2.getTime(); > > assertTrue(child2.isSuccessful()); >- assertEquals(200, child2.getBytes()); >+ assertEquals(200, child2.getBytesAsLong()); > assertEquals("Child2 Sample", child2.getSampleLabel()); > assertEquals(1, child2.getSampleCount()); > assertEquals(0, child2.getSubResults().length); >@@ -266,7 +266,7 @@ > parent.addSubResult(child1); > parent.addSubResult(child2); > assertTrue(parent.isSuccessful()); >- assertEquals(600, parent.getBytes()); >+ assertEquals(600, parent.getBytesAsLong()); > assertEquals("Parent Sample", parent.getSampleLabel()); > assertEquals(1, parent.getSampleCount()); > assertEquals(2, parent.getSubResults().length);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53039
:
34337
|
34338
|
34347
|
34348
| 34355