Let’s say you want to capture the http response of a page, but it redirects you (code 302). The normal way you might capture the HTTP status code is capturing it in a variable:
HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
This would be put after the page request in the script. However, this will only capture the LAST status code received. If there is a redirection in between, it will not be captured. So how do you get the first one? Capture the response header using a correlation. Use the web_reg_save_param function with the following arguments:
Use the “ORD=ALL” argument to capture all occurrences. Use the “Search=Headers” argument to search the response header only.
Here is an example:
web_reg_save_param("response","LB=HTTP/1.1 ", "RB= ", "Search=Headers" ,"ORD=ALL", LAST);
Then just spit out “response” to the output log as a message.
Did you enjoy this article? Help spread the word by sharing:
Engage in the conversation and leave a comment:
About Scott Moore (153 articles)
With over 20 years of IT experience with various platforms and technologies, Scott has tested some of the largest applications and infrastructures in the world. He is a Certified Instructor and Certified Product Consultant in HP’s LoadRunner and Performance Center products. He currently holds HP certifications for ASE, ASC, and CI. A thought leader in the APM space, he speaks regularly at IT conferences and events