how to parse a value in JMeter sampler result

I am unable to calculate the response header size in Jmeter.

I want to calculate the response header size and i tried below option but i was unsuccessful. Option 1: Parse the value returned in Sampler result --> i do not have an inbuilt option. Option 2: Store the response header in a variable and calculate the length using var.length() function. --> since the response header have new line feeds, the .length function did not work.

Can anyone please suggest me to calculate the response header size in bytes.

Thanks in advance,

Regards, Hari

2 answers

  • answered 2018-04-17 06:06 Dmitri T

    It should be something like:


    JMeter Response Headers Size

    Where prev is a shorthand to SampleResult class instance.

    Be aware that starting from JMeter 3.1 users are encouraged to switch to JSR223 Test Elements and Groovy language for any form of scripting as Groovy:

    • is more Java-compliant including modern language features
    • has enhancements on top of Java SDK
    • has much better performance

    See Apache Groovy - Why and How You Should Use It article for more details

  • answered 2018-04-17 06:06 Hari

    We can also do in BeanShell and below is the snippet of the Code

    Add a Bean Shell Post Processor


    response_Header = prev.getResponseHeaders(); 
    response_Header_Size = new Integer(response_Header.length()); 
    vars.put("response_Header_Size", response_Header_Size.toString());

    Works for Jmeter 2.13