Highlighted
Contributor.
Contributor.
3088 views

How to save parameters in request headers between several redirections

Jump to solution

Hi,

I'm trying to save parameters in a redirection url. First of all I send a request of url https://plc-xsac-plc-web.cfapps.sap.hana.ondemand.com/install, then it will redirect to a authentication page and response a parameter VCAP_ID which is I need to save, then redirect automatically to a login page. I tried to use web_reg_save_param to save but failed, it said the specified boundaries were not found in the response. The VCAP_ID is actually in the request headers in the last login page, not response. So how can I save the parameters in a url between serveral redirections?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: How to save parameters in request headers between several redirections

Jump to solution

I did a little test myself on a page with double redirect (301). I had no differences in cookies, so I looked to an header field "LB=Content-Length: "

I was able to capture the both values of the redirects by using

"Ordinal=All", SEARCH_FILTERS, "Scope=Headers", "IgnoreRedirections=off"

It might be that "Ordinal=All", in combination with "IgnoreRedirections=off" implies that LR will look into the responses of each redirect.

So I suggest to experiment with:

web_reg_save_param_ex("ParamName=__VCAP_ID__",
                          "LB=__VCAP_ID__=",
                          "RB=;",
                          "Ordinal=All",
                          "Notfound=warning"
                          SEARCH_FILTERS,
                          "IgnoreRedirections=off",
                          "Scope=Cookies",
                          LAST);

 

Signature:
Reward community members who take time to respond and help.

View solution in original post

0 Likes
7 Replies
Highlighted
Super Contributor.
Super Contributor.

Re: How to save parameters in request headers between several redirections

Jump to solution

You're pretty vauge on which protocol or language you are using, so I'll assume you're using Web HTTP/HTML protocol an C. 

 

I assume you can 

First quick fix: read the documentation about and use the function web_set_max_html_param_len()
Sample call: web_set_max_html_param_len("10240");

Second: read the doumentation of web_reg_save_param_ex() - or of the depracated web_reg_save_param() - and the parts of Search Filters for Save Parameter Registration Functions.

 

I am assuming you have seen you actually are getting the VCAP_ID and now the boundaries of this identification.

 

Please reply with your solution and some code snippets so others can learn too.

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: How to save parameters in request headers between several redirections

Jump to solution

You can only capture data from a response with web_reg_save* functions. You have to analyse the data flow from the redirected base URL up to the redirected URL. Normally A redirect sets up extra header info(?) or cookies that are returned with the next request.

As far as I know a redirect will not add an header out of the blue. Most of the time data is added in redirect-URL or cookies.

Are you sure you get an 300-303 or 307 on the first GET? It might be that you get a normal response with auto-executed java script that simulates a redirect and sets up extra headers etc.

Note:

You might checkout Search Filter  "IgnoreRedirections=Yes" when you want to get information of response that is directed to.

You might play with your recording options (HTTP Properties --> Advanced) and experiment with 'Generate API calls for specific HTTP status codes'. and see what you can do with that.

 

Success.

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Contributor.
Contributor.

Re: How to save parameters in request headers between several redirections

Jump to solution

Sorry for my vauge description, and yes I use C language to generate my script. For the redirection process, it's auth > authentication page > login page. The value I need is in the response header of the authentication request, and the request has no response body.

here's my script:

web_set_max_html_param_len("10240");
    web_reg_save_param_ex("ParamName=__VCAP_ID__",
                          "LB=Set-Cookie: __VCAP_ID__\=",
                          "RB=; Path=/; HttpOnly; Secure\r\n",
                          SEARCH_FILTERS,
                          "IgnoreRedirections=off",
                          "Scope=Headers",
                          "RequestUrl=https://plc.authentication.sap.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-xsac-plc-dev!t1248&redirect_uri=https:/plc-xsac-plc-web.cfapps.sap.hana.ondemand.com/login/callback",
                          LAST);
                          
    
        web_custom_request("Auth",
         authURLArg,
         "Method=GET", 
        "Resource=1", 
        "RecContentType=application/json", 
        "Referer=", 
        "Snapshot=t2.inf", 
        "Mode=HTTP", 
        "EncType=",    
         LAST);

The output is in the attached file. Thanks for your help!

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: How to save parameters in request headers between several redirections

Jump to solution

A few remarks:

I think that you should use "IgnoreRedirections=On"; I needed to read the function help 3 times to come to that conclusion. (Or at least try with both options).

You are looking for a cookie. Note that a cookie is autmatically returned. I would not trust on the order of a cookie in the cookie list. I think that LR is formatting the response in the log, but the web_reg_save_param* function monitor the raw data. (Use a took like HTTPWatch to examine the data send in raw format). So I would use as boundaries: "LB=__VCAP_ID__=", "RB=;"

There is a separate search option for cookies: "Scope=Cookies"

Signature:
Reward community members who take time to respond and help.
0 Likes
Highlighted
Contributor.
Contributor.

Re: How to save parameters in request headers between several redirections

Jump to solution

I just tried all your suggestions, but still failed. 

web_set_max_html_param_len("10240");
    web_reg_save_param_ex("ParamName=__VCAP_ID__",
                          "LB=__VCAP_ID__",
                          "RB=;",
                          SEARCH_FILTERS,
                          "IgnoreRedirections=on",
                          "Scope=Cookies",
                          "RequestUrl=https://plc.authentication.sap.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-xsac-plc-dev!t1248&redirect_uri=https:/plc-xsac-plc-web.cfapps.sap.hana.ondemand.com/login/callback",
                          LAST);

And I got the raw data from Fiddler like this:

HTTP/1.1 302 Found
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 0
Date: Fri, 22 Jun 2018 06:58:14 GMT
Expires: 0
Location: https://plc.authentication.sap.hana.ondemand.com/login
Pragma: no-cache
Set-Cookie: X-Uaa-Csrf=QeRzouyhqXBMKUNyjnxF1l; Max-Age=86400; Expires=Sat, 23-Jun-2018 06:58:15 GMT; Path=/; HttpOnly
Set-Cookie: JSESSIONID=2956590F2B6F1716FDD1C70701CC9326; Path=/; Secure; HttpOnly
Set-Cookie: __VCAP_ID__=410325f8-3eab-4848-6a27-7f5b; Path=/; HttpOnly; Secure
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Vcap-Request-Id: c165f2ff-c857-49fd-500e-69bd79c0c0b5
X-Xss-Protection: 1; mode=block

                          

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Re: How to save parameters in request headers between several redirections

Jump to solution

I did a little test myself on a page with double redirect (301). I had no differences in cookies, so I looked to an header field "LB=Content-Length: "

I was able to capture the both values of the redirects by using

"Ordinal=All", SEARCH_FILTERS, "Scope=Headers", "IgnoreRedirections=off"

It might be that "Ordinal=All", in combination with "IgnoreRedirections=off" implies that LR will look into the responses of each redirect.

So I suggest to experiment with:

web_reg_save_param_ex("ParamName=__VCAP_ID__",
                          "LB=__VCAP_ID__=",
                          "RB=;",
                          "Ordinal=All",
                          "Notfound=warning"
                          SEARCH_FILTERS,
                          "IgnoreRedirections=off",
                          "Scope=Cookies",
                          LAST);

 

Signature:
Reward community members who take time to respond and help.

View solution in original post

0 Likes
Highlighted
Contributor.
Contributor.

Re: How to save parameters in request headers between several redirections

Jump to solution

Thanks a lot, after I just change the Ordinal = 1, I can get the correct parameter value

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.