0
votes

We are using JAVA implementation for one of the requests.In the request we are uploading a file. Request doesn't work when HTTPCLIENT4 implementation is selected.The request works fine with previous Jmeter version with HTTPCLIENT3.1 implementation. We need to capture bytes sent in results. How to capture bytes sent through JAVA implementation in HTTP Request sampler

1
You can't. Java implementation simply doesn't set that parameter. You can submit it as a bug to JMeter team. A better solution would be figuring out why HTTPCLIENT4 doesn't work for you. A (not very reliable) workaround is to get request headers, and check if it has Content-Length field. That field will tell you the size of the sent content, excluding headers. You can do it using JSR223 PostProcessor - Kiril S.

1 Answers

0
votes

Sent bytes is basically a combination of URL + headers + body so you can calculate it yourself using JSR223 PostProcessor and code like:

def url = sampler.getUrl().toString().length()
def headers = prev.getHeadersSize()
def body = 0;
sampler.getHTTPFiles().each {file ->
    body += new File(file.getPath()).length()
}

prev.setSentBytes(url + headers + body)

Where:

  • sampler is an instance of HTTPSamplerProxy where you can get all files which you're sending with the request
  • prev is an instance of HTTPSampleResult where you can get URL and Headers and also override Sent Bytes field.

See The Groovy Templates Cheat Sheet for JMeter to see what else you can do with Groovy and how.