GET request using LWP::UserAgent returns 200 OK but Firefox 302 Foundby bliako (Monsignor)
|on Mar 09, 2018 at 15:08 UTC||Need Help??|
bliako has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed Archontes of Perl Wisdom,
I am sorry that this is a very vague question because I can not share the details of the request but also because I can test this only once a day.
In a particular scraping exercise I observe that my browser (Firefox 48 and firebug) sends a GET to the server and receives a "302 Found" server response. However, when I do the same programmatically with LWP I get a 200 OK server response back.
The whole exercice consists of: POST, GET, GET.
The POST returns a 302 and a "Location" header (RLOC1). This succeeds in LWP.
RLOC1 is relative URL in the form of "../../ABC/xyz.jsp" and so I make it absolute by inserting protocol and server name and replacing "../../" with absolute path. I assume absolute path is correct because I can verify with what I see in browser/firebug. And so I now have absolute url LOC1.
Next, I GET to LOC1 using LWP, expecting to get 302, like I get in my browser, but I get 200 OK. (and no "Location" in headers to continue with my next and final GET).
I am quite sure the request headers (including cookies, referer and user-agent string) are the same in both although I am now using LWP::ConsoleLogger::Easy in order to verify that exactly.
I am very sure that the GET params sent to the server with LWP and browser are identical (and there are no character escape issues).
Assuming request headers and GET params are identical between LWP and browser, are there other factors that can cause the remote server to behave differently when using LWP?