> >>>> + /** >>>> + * Get Content-Length value from headers >>>> + * @param headers >>>> + * @return Content-Length value >>>> + */ >>>> + public static int getHeaderContentLength(String headers) { >>>> + LinkedHashMap<String, String> lhm = >>>> JMeterUtils.parseHeaders(headers); >>>> + Set<Entry<String, String>> keySet = lhm.entrySet(); >>>> + for (Entry<String, String> entry : keySet) { >>>> + if (entry.getKey().equals(HEADER_CONTENT_LENGTH)) { >>>> + return Integer.parseInt(entry.getValue()); >>>> + } >>>> + } >>>> + return 0; // Content-Length not found >>>> >>>> >>> This does not work for chunked input. It might be better to store the >>> actual response size when receiving the response, rather than trying >>> to calculate it later. >>> >>> >> Ok, store in sampleresult when receiving the response. If 0 (no value), >> the response data size is used. >> >> >> With my last submission (r1088748), I try to respond to your feedback. >> Please say me if another thing to improve. >> > The problem of chunked responses still exists - such responses don't > have a Content-Length header. > > One way round this would be to wrap the input Stream with a > org.apache.commons.io.input.CountingInputStream. > I don't think this will affect performance adversely. > > Does that make sense? >
Yes may be a good idea. Since your last commit on HC4Impl, entity.getContentLength() return -1 (unknown size) (but http response have a content-length define) I thinks the ResponseContentEncoding class which decompress stream is the cause. On HC4, I try to use a CountingInputStream on instream, but the return size is uncompressed. // InputStream instream = entity.getContent(); InputStream instream = new CountingInputStream(entity.getContent()); res.setResponseData(readResponse(res, instream, (int) entity.getContentLength())); int cnt = ((CountingInputStream) instream).getCount(); log.debug("CNT=" + cnt); I thinks that CountingInputStream must be in more deep in code, directly in HttpClient, or inside the Gzip/deflate input stream? Milamber > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@jakarta.apache.org > For additional commands, e-mail: dev-h...@jakarta.apache.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: dev-h...@jakarta.apache.org