jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heiko Robert <heiko.rob...@ecm4u.de>
Subject Re: HTTP Header Manager uses old variable values?
Date Wed, 13 Jan 2010 12:42:48 GMT
sebb,

thanks a lot - that works !!! ;-)

For everybody who tries to populate a GUID into a HTTP-Header variable 
here is the full solution:

define a user variable:
MyGUIDScript =
var chars = '0123456789abcdef'.split(''); var uuid = [], rnd = 
Math.random, r; uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; uuid[14] 
= '4';  for (var i = 0; i < 36; i++) { if (!uuid[i]) {r = 0 | rnd()*16; 
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf]; } }; uuid.join('');

In the HTTP Header Manager:
X-GUID = ${__javaScript(${MyGUIDScript},GUID)}

sebb schrieb:
> On 13/01/2010, Heiko Robert <heiko.robert@ecm4u.de> wrote:
>   
>> Hi,
>>
>>  when I use HTTP Header Manager to set HTTP header variables old values are
>> used. Has anybody an idea what I'm doing wrong?
>>     
>
> Header Manager is a Configuration element, and is processed before the
> thread starts.
>
> You can use functions on the Test Plan to define variables.
>
>   
>>  My Testplan: user defined variables: GUID = not set
>>    BSF PreProcessor: setting values to variable GUID
>>    Simple Controller
>>       HTTP Request ${GUID}
>>          HTTP Header Manager: setting X-GUID = ${GUID}
>>       HTTP Request ${GUID}
>>          HTTP Header Manager: setting X-GUID = ${GUID}
>>    View Results Tree
>>
>>  The results:
>>
>>  HTTP Request 472c63c2-63d5-44c4-a717-9252e2a7f8bf
>>  GET
>> http://www.apache.org/?X-GUID=472c63c2-63d5-44c4-a717-9252e2a7f8bf
>>  Request Headers:
>>  X-GUID: not set
>>
>>  HTTP Request 472c63c2-63d5-44c4-a717-9252e2a7f8bf
>>  GET
>> http://www.apache.org/?X-GUID=e6df3a7d-e054-444b-9ef8-7c9c2803821e
>>  Request Headers:
>>  X-GUID: 472c63c2-63d5-44c4-a717-9252e2a7f8bf
>>
>>  I tried with latest jmeter versions and also with the nightly build
>>
>>  Thanks
>>  Heiko
>>
>> ---------------------------------------------------------------------
>>  To unsubscribe, e-mail:
>> jmeter-user-unsubscribe@jakarta.apache.org
>>  For additional commands, e-mail:
>> jmeter-user-help@jakarta.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message