Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Thanks, everyone!

by bbfu (Curate)
on Jan 13, 2001 at 04:50 UTC ( [id://51527]=note: print w/replies, xml ) Need Help??


in reply to HTTP GET without LWP

I appreciate all the help from everyone!

The problem was pretty much exactly what sutch said. I've updated the request to use HTTP/1.1 and the Host: field. I might take the advice and use the User-Agent: field as well when I read more about it.

What I've got now (below) works. Though I realize this is a pretty primative hack, I just don't have access to LWP (at the moment).

Again, thanks for all the help!

#!/usr/bin/perl -w use IO::Socket; unless (@ARGV) { die "usage: $0 URL\n" } $EOL = "\015\012"; $BLANK = $EOL x 2; $sep = (@ARGV > 1) ? "-------------------\n" : ""; foreach $url ( @ARGV ) { unless($url =~ m{^http://(.*?)/(.*)$}) { print "$0: invalid url: $ +url\n"; next } $host = $1; $rest = $2; $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => "http(80)", ); unless ($remote) { die "Cannot connect to http daemon on $host\n" +} $remote->autoflush(1); print $remote "GET /$rest HTTP/1.1". $EOL . "Host: $host" . $BLANK +; while ( <$remote> ) { print } print "\n$sep"; close $remote; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://51527]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-23 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found