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; }
In reply to Thanks, everyone!
by bbfu
in thread HTTP GET without LWP
by bbfu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |