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.

More details:

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?

Any ideas?


In reply to GET request using LWP::UserAgent returns 200 OK but Firefox 302 Found by bliako

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.