D
dan baker
I have a little script that has been working fine for a long time
which feeds some parameters to a script on a remote server and
extracts some information from the response. Recently, the UserAgent
portion of the script has been returning an error response 302 "server
temporarily unavailable..."
however, if I go to the remote server and manually use their input
FORM, I get a results... so I am suspecting that the site is doing
some other check on where the request is originating from. I tried
grabbing a copy of their form and making sure that all the field names
and values my UserAgent is sending are the same as what their FORM is
sending.
is there some other information I can pass along thru UserAgent to
make it look more like the request originates from the remote server
rather than from my domain? Do variables like HTTP_HOST and others get
passed along? Can they be set by UserAgent?
A snippet of my code looks like:
use LWP::UserAgent ;
use HTTP::Request::Common ;
my $ua = LWP::UserAgent->new;
my $req = POST 'http://www.remotehost.com/cgi-bin/theirscript.jsp',
[
Selection => 1,
Submit.x => 0,
Submit.y => 0,
address => $Address ,
zipcode => $Zip
] ;
my $response = $ua->request($req);
unless ( $response->is_success ) { # request failed for some reason
$tempString = $response->status_line ;
print STDERR "server gave error 302 \n" ;
}
which feeds some parameters to a script on a remote server and
extracts some information from the response. Recently, the UserAgent
portion of the script has been returning an error response 302 "server
temporarily unavailable..."
however, if I go to the remote server and manually use their input
FORM, I get a results... so I am suspecting that the site is doing
some other check on where the request is originating from. I tried
grabbing a copy of their form and making sure that all the field names
and values my UserAgent is sending are the same as what their FORM is
sending.
is there some other information I can pass along thru UserAgent to
make it look more like the request originates from the remote server
rather than from my domain? Do variables like HTTP_HOST and others get
passed along? Can they be set by UserAgent?
A snippet of my code looks like:
use LWP::UserAgent ;
use HTTP::Request::Common ;
my $ua = LWP::UserAgent->new;
my $req = POST 'http://www.remotehost.com/cgi-bin/theirscript.jsp',
[
Selection => 1,
Submit.x => 0,
Submit.y => 0,
address => $Address ,
zipcode => $Zip
] ;
my $response = $ua->request($req);
unless ( $response->is_success ) { # request failed for some reason
$tempString = $response->status_line ;
print STDERR "server gave error 302 \n" ;
}