jmeter - Manipulate post body of httpsampler before request -
i'm testing eclipse-rap application jmeter.
in rap client (javascript-framework in browser) communicates server on json-based protocol.
a message looks this:
{"head":{"requestcounter":3,"uisessionid":"832834"},"operations":[["set","w1",{"bounds": [0,0,1680,893],"cursorlocation":[1262,-1]}]]}
as see there session-id stored in uisessionid. extracted id using "regular expression extractor" , stored in variable named
ui_session_id`.
edited raw "post body" of recorded http-request:
{"head":{"requestcounter":3,"uisessionid":"${ui_session_id}"},"operations":[["set","w1",{"bounds": [0,0,1680,893],"cursorlocation":[1262,-1]}]]}
and works.
but have alter each post-body of each http-request can lot. after research thought using "beanshell preprocessor" right thing, but:
var sampler = ctx.getcurrentsampler();
would give me httpsampler , did not find method allows me retrieve post-body, replace session-id variable , set altered post-body.
javadoc: http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/httpsampler.html
do know way can replace uisessionid
variable without changing every request manually?
you don't have to. uisessionid
header has been introduced in milestone version in preparation multiple browser-tab support in rap, has been replaced mechanism not use header parameter anymore.
as of rap 2.1 rc1, client attaches “connection id” every post request in url parameter cid
. parameter not affect load tests, , don't have remove recording. since every jmeter thread gets own httpsession, it's not problem threads have same cid.
one reason change ability load test rap applications without kind of problems you've been struggling with.
Comments
Post a Comment