Reputation: 81
I am setting up a performance test with load I have set of 100 GET requests sample request as below:
http://34.202.108.112:8080/adserver/html5/inwapads/?sleepAfter=0&adFormat=preappvideo&ak=c39ca252e3605ca216f05d4c6ed18b08&version=1.0&fullscreen=1&vdo=1&requester=dashbid&channelType=site&pageURL=http%3A%2F%2Fibtimes.co.uk&siteName=ibtimes.co.uk&refURL=ibtimes.co.uk&*ipAddress=212.232.34.134*&ua=Mozilla%2F5.0+%28Linux%3B+Android+5.0.1%3B+SCH-R970+Build%2FLRX22C%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F47.0.2526.83+Mobile+Safari%2F537.36&cb=1477379953087252374&target_params=latlong=57.6198/39.8554|geoType=1&size=x&dnt=0&output=vast;vdocookieid=af7d5dc67d7cd4e9f4a56f09d0b1046b 2351daf4-3fb3-4d5c-890c-c32672e036df 35c720f4-5bb3-45f3-b5b1-be9fcd5f2f5d
All set of requests have different ipAddress
, What I want to add X-Forwarded-For
Request Header for each request which has value same as ipAddress
in request .
Any suggestions would be of great help.
Upvotes: 1
Views: 2785
Reputation: 168122
If you are getting these IP addresses from CSV file you can just add a HTTP Header Manager and configure it like:
If you have 100 requests with hard-coded IP addresses (i.e. coming from recording) it is still possible, but you will need to do some scripting
Put the following code into JSR223 PreProcessor "Script" area
import org.apache.jmeter.protocol.http.control.Header
def address = sampler.getArguments().getArgumentsAsMap().get("ipAddress")
def headerManager = sampler.getHeaderManager()
headerManager.removeHeaderNamed("X-Forwarded-For")
headerManager.add(new Header("X-Forwarded-For", address))
The above code will look for ipAddress
request parameter and if it will be found it will add the relevant X-Forwarded-For
header to the request
Upvotes: 2