dougis has asked for the wisdom of the Perl Monks concerning the following question:
The code works fine under Active Perl in windows, but I am now generating a file from a unix box.
The issue is when I run the code under unix I get a response 302 (Redirect loop detected) and the post doesn't occur.
Here is the primary code (all variables have been initialized to the proper values, and the use statements are all in place)
is_succes never gets set and I always get a 302 result even though I have added post to the requests_redirectable array.my $ua = LWP::UserAgent->new; # Allow post redirects to happen push @{ $ua->requests_redirectable }, 'POST'; my $result = $ua->request(POST $PostURL, Content_Type => 'form-data', Content => [ user => $UserID, password => $Password, trk_code => $TheTrackCode, upfile => [$UploadFile], ]); if ($result->is_success) { # means we got a success message back my $ReturnText = $result->content(); if (index($ReturnText, "You successfully uploaded file") > -1) { print "Upload succeeded\n"; $ReturnVal = 1; } else { print "Upload failed\n$ReturnText\n"; } } else { print "ERROR OCCURED (Code was " . $result->code() . ")\n"; my $ReturnText = $result->content(); print "Return Text was\n$ReturnText\n"; }
The 302 is technically correct as it is a scriptalias cgi on apache that is being posted to, but I thought requests_redirectable was supposed to allow it to post properly.
TIA for any help you can offer. (sorry for the long post, but I wanted to give any info needed)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTP form Post, Getting redirect response
by perlplexer (Hermit) on Apr 26, 2002 at 15:20 UTC | |
by dougis (Initiate) on Apr 26, 2002 at 15:49 UTC | |
|
Re: HTTP form Post, Getting redirect response
by LiTinOveWeedle (Scribe) on May 23, 2002 at 11:36 UTC |