develooper Front page | perl.libwww | Postings from March 2001

bleary eyed

Thread Next
From:
Jeff Orrok
Date:
March 21, 2001 00:52
Subject:
bleary eyed
Message ID:
3AB86BAE.EB18F201@databright.com
It's past my bedtime, and I can't figure out why the following generates
a 404 error, when I cat into it a file with a url on a line followed by
a series of lines of the format field=value

But when I hardcode the url after the POST => instead of $_  and cat in
the same file, then it gives me the page.

Someone wanna help me?

while(<>){  
  chop;
  my $ua = LWP::UserAgent->new;
  my $req = HTTP::Request->new( POST => $_ );  
  $req->content_type('application/x-www-form-urlencoded');
  $req->content(''); 
  $latch = 0;
  while(<>){
    chop;
    $req->add_content( ($latch?'&':'') . $_ );
    $latch = 1;
  } # while 
  my $res = $ua->request($req);  
  
  print "Content-Type: text/html\n\n";
  print $res->content;  
} # while

--
:-J
--

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About