Example:
When visiting http://www.mercury.com, user will be redirected to a different location. How to capture the redirected URL.
Solution:
Use web_reg_save_param()
When that the server redirects a HTTP request to another URL, it normally does that by sending a HTTP 302 Moved header. To verify
1. Run the script in extended log with "data retuned by server' turned on
2. Check the execution log for "302 moved'
You can also see that along with this header, the server also sends the following header information:
"Location:."
The URL specified in the "Location' header will be the URL that the original HTTP request be redirected to. To capture this URL, you have to capture the string between "Location:" and "\r\n" (end of line).
Example:
Action()
{
//use the correlation statement to capture the redirection
web_reg_save_param ("Redirection", "LB=Location: ","RB=\r\n" ,LAST );
//Visit Mercury homepage
web_url("Mercury","URL=http://www.mercury.com/", LAST);
//Print the redirected URL
lr_message("redirected address = %s", lr_eval_string("{Redirection}"));
return 0;
}
When visiting http://www.mercury.com, user will be redirected to a different location. How to capture the redirected URL.
Solution:
Use web_reg_save_param()
When that the server redirects a HTTP request to another URL, it normally does that by sending a HTTP 302 Moved header. To verify
1. Run the script in extended log with "data retuned by server' turned on
2. Check the execution log for "302 moved'
You can also see that along with this header, the server also sends the following header information:
"Location:
The URL specified in the "Location' header will be the URL that the original HTTP request be redirected to. To capture this URL, you have to capture the string between "Location:" and "\r\n" (end of line).
Example:
Action()
{
//use the correlation statement to capture the redirection
web_reg_save_param ("Redirection", "LB=Location: ","RB=\r\n" ,LAST );
//Visit Mercury homepage
web_url("Mercury","URL=http://www.mercury.com/", LAST);
//Print the redirected URL
lr_message("redirected address = %s", lr_eval_string("{Redirection}"));
return 0;
}
No comments:
Post a Comment