in reply to POST with LWP yields HTTP 302 Not Allowed - Too bad for me?

No, it means that your request was being redirected to http://148.129.65.3:80/fwauthredirect148.129.65.9id0003864295 and you need to resubmit it to that URI.

When your browser gets a 302 (client-side redirect) message, it automagically follows it without bothering you. When you use LWP, you're taking control of things at a lower level, so you have to notice the 302, get the returned Location: header, and resubmit the request to that address yourself.

  • Comment on Re: POST with LWP yields HTTP 302 Not Allowed - Too bad for me?

Replies are listed 'Best First'.
Re: Re: POST with LWP yields HTTP 302 Not Allowed - Too bad for me?
by Shizzle (Novice) on May 15, 2002 at 16:03 UTC
    Thanks for your reply, although I'm still misisng it. I ran the program again, went down to the line that had the "Location:" header, and copied the redirection URI into my code, which is below:

    #!/opt/gnu-irix/bin/perl use strict; use HTTP::Request::Common; use LWP::UserAgent; my $ua = new LWP::UserAgent; #my $formurl = 'http://www.usps.com:80/cgi-bin/zip4/zip4inq2'; my $formurl = 'http://148.129.65.3:80/fwauthredirect148.129.65.9id0003869786'; my $formdata = [ 'Firm' => '', 'Urbanization' => '', 'Delivery Address' => '100 Southland Vlg', 'City' => '', 'State' => '', 'Zip Code' => '36079-3044', 'Submit' => 'Process' ]; print $formurl, "\n"; my $resp = $ua->request(POST $formurl, $formdata); if ($resp->is_success()) { print $resp->content(); } else { print "Problem\n\n", $resp->as_string(); }

    Running the program generated a similar response:

    HTTP/1.0 302 (Found) Not Allowed Location: http://148.129.65.3:80/fwauthredirect148.129.65.9id000386993 +7 Content-Length: 120 Content-Type: text/html Client-Date: Wed, 15 May 2002 15:57:42 GMT Client-Peer: 56.0.78.101:80 Your request is being redirected to :<a href="http://148.129.65.3:80/f +wauthredirect148.129.65.9id0003869937">here</a>.

    It appears that I simply got redirected again. Please advise. Thanks.