in reply to Unable to access restricted URL resource (GET) 302 redirect msg - using HTTP::Request::Generator

HTTP::Request::Generator is for generating HTTP requests, for example for scanning multiple hosts for a set of URLs. It is not for executing the sequence of requests and certainly not for following requests.

LWP::UserAgent can automatically/transparently follow 302 requests, but I don't know if it also transforms a POST request into a GET request after redirect. If not, you will have to do that yourself, but you will have to do that with any kind of HTTP request, no matter how you got it (manually, or from HTTP::Request::Generator). See the response_redirect handler for where you can implement the change from POST to GET on redirect.

Update: If you want to have your Perl script act more like a browser, consider using WWW::Mechanize, which extends LWP::UserAgent to act more like a browser.

  • Comment on Re: Unable to access restricted URL resource (GET) 302 redirect msg - using HTTP::Request::Generator

Replies are listed 'Best First'.
Re^2: Unable to access restricted URL resource (GET) 302 redirect msg - using HTTP::Request::Generator
by tobyink (Canon) on Oct 10, 2020 at 21:01 UTC

    "LWP::UserAgent can automatically/transparently follow 302 requests, but I don't know if it also transforms a POST request into a GET request after redirect."

    For HTTP 302 and HTTP 303 redirects, it transforms non-GET/HEAD requests into GET requests upon redirection.