Shrikant More
Shrikant More

Reputation: 146

capturing response header in Jmeter and use it as variable in another request

I want to capture response Header Location : specifically 100 number so i can use it as variable in another request. How can i do this ?

Request

Remote Address: 57.98.32.25:80

Request URL:http://57.98.32.25/new_events

Request Method:POST

Status Code:200 OK

Response Headers

Cache-Control:no-cache
Connection:close Content-Encoding:gzip
Content-Length:105
Content-Type:text/html; Date:Thu, 27 Aug 2015 06:37:31 GMT Location:http://57.98.32.25/new_events/100
Server:Apache/2.2.15

Upvotes: 3

Views: 11351

Answers (1)

Dmitri T
Dmitri T

Reputation: 168147

You can do it via Regular Expression Extractor configured as follows:

  • Field to check: Response Headers
  • Reference Name: anything meaningful, i.e. location
  • Regular Expression: new_events/(\d+)
  • Template: $1$

Regular Expression Extractor

You may also need to switch "Apply to" value to "Main sample and sub-samples" if there are redirects and the Location header is not available in the main sample, use View Results Tree listener to determine it.

Refer extracted value as ${location} or ${__V(location)} where required.

Upvotes: 13

Related Questions