Highlighted
Absent Member.
Absent Member.
13138 views

Inserting HTTP headers with LoadRunner script?

I've searched around the web, but not found this anywhere, but is it possible within a loadrunner script, to set http headers that will get passed to my test server when the connection gets made?  And additionally, can this header be parameterized?

 

Thanks!

0 Likes
18 Replies
Highlighted
Absent Member.
Absent Member.

Re: Inserting HTTP headers with LoadRunner script?

Most definitely. web_add_header() will let you do that and it is 100% paramatisable - you just pass it strings.

 

Headers, cookies, html params, etc - they're all very easy to play with. Just look in the help for all the functions prefixed by web_.

 

Oliver
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Inserting HTTP headers with LoadRunner script?

Great, thank you!

0 Likes
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: Inserting HTTP headers with LoadRunner script?

Hi,

 

you can also use the web_add_auto_header function, which adds a header for all subsequent calls against the server, so you don't have to place the header in front of each web_url or submit statement.

 

Regards

Chris

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Inserting HTTP headers with LoadRunner script?

Can you give me an example on how to we parametize the header values?

 

Vikranth

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Inserting HTTP headers with LoadRunner script?

Don't we need to remove the header after adding it using the web_remove_auto_header() if we need to use this header in one action only?

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

How to pass colon(:) as part of the header name in loadrunner script.

 
We have a scenario where we have to pass ':path' as header name in LoadRunner script.
For example web_add_header(":path", "*********");
It is a mandatory header. But we are getting below error message while passing above header.
Error -26669: Header name invalid: NULL, empty, consists of white spaces only or contains embedded spaces or colons
0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: How to pass colon(:) as part of the header name in loadrunner script.

Hi Kavithakm37,

I think there's some extra characters on the "Value" argument, linke "\r" or "\n" at the end of the string. Can you check it? If it doesn't resolve the issue, please send the entire web_add_header() function of your script. 

Let me know!

Lorenzo

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: How to pass colon(:) as part of the header name in loadrunner script.

Mybe the problem is on the "Name" of your header: try to delete the ":" character, and let only the "path" name.

Lorenzo

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: How to pass colon(:) as part of the header name in loadrunner script.

Yes we tried it already, loadrunner is accepting but application is not accepting it.

We are getting 403 Forbidden error if we pass without colon.

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: How to pass colon(:) as part of the header name in loadrunner script.

Thank you for your timely reply

The format is like below:

Web_add_header(":path", "here goes the path");

Problem is with the name, not the value.

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: How to pass colon(:) as part of the header name in loadrunner script.

I think you haven't to put the ":" character before the header name "path". What is the canonical name of the header? If it is something like "ServiceName:path", I suggest you to copy the entire string. 

Let me know, 

Lorenzo

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.