On Saturday, July 13, 2002, at 08:06 , FLAHERTY, JIM-CONT wrote:
[..]
>         unless ($remote) { die "cannot connect to http daemon on $host" }
>
>         $remote->autoflush(1);
[..]
>    print LOG9 " $remote \"GET $document HTTP/1.0\" . $BLANK";
>
>          while ( <$remote> ) { print LOG9 }
[..]

p0: way too much work in the long run, you clearly want
to become friends with

        use LWP::UserAgent;
        use HTTP::Request;
        
p1: we've all tried variations on this mine just used Sockets....

http://www.wetware.com/drieux/pbl/perlTrick/subStuff/SimpleLib/WebAccess.txt

        my $msg = "GET $dtk_url HTTP/1.1\nHost: $dtk_host:$dtk_port\n\n";

        print $dtk_sock $msg;

what you technically missed in the HTTP spect is
the second line that is required

p2: I have been playing around with some simple demonstrations of
how to bollock up the mess -

http://www.wetware.com/drieux/pbl/perlTrick/CBO/jobBot/p1b.txt

  sub get_web_page {
     my ($the_url , $parser, $method, $msg) = @_;
                
     $method ||= 'GET'; # so that we have a default here

     my $return_string =  "Your Request Failed\n";

     my $ua = LWP::UserAgent->new;
     my $req = HTTP::Request->new($method => $the_url );
     if ($msg && $method eq 'POST') {
         $req->header('Content-type', 'application/x-www-form-urlencoded');
         $req->content($msg);
     }
     my $res = $ua->request($req);
     if ($res->is_success) {
         #
         # since we know that we want to have parsers passed in
         # as a rule of thumb - why not just, well, have this fixed
         #
         $return_string = ($parser)? $parser->($res): $res->content;
     } else {
         $return_string .= $res->error_as_HTML if ($res->is_error);
     }
     return($return_string);
  } # end of get_web_page


HTH....

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to