scottknight has asked for the wisdom of the Perl Monks concerning the following question:
This has been working just fine until I came up against a D-Link modem that only spits back 501 Not Implemented messages at it. I found that it also kind of works on a Linksys wireless access point since it will happily get the root url, but a request for any other doc will return a 403 Error.use IO::Socket::INET; use MIME::Base64 (); $pass64 = MIME::Base64::encode_base64("$username:$password"); my $sock; unless ($sock = new IO::Socket::INET (PeerAddr => $host, PeerPort => $ +port, Proto => 'tcp', Timeout => 5)) { $errormessage = $tr{'could not connect to http://$host:$port/$file +name'}; return '0'; } $sock->print("GET /".$filename." HTTP/1.0\r\n"); $sock->print("Host: $host\r\n"); $sock->print("Authorization: Basic $pass64\r\n"); $sock->print("\r\n"); while (<$sock>) { printf $_; } close($sock);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with IO::Socket::INET
by dave_the_m (Monsignor) on Nov 29, 2004 at 15:14 UTC | |
by scottknight (Novice) on Nov 29, 2004 at 17:20 UTC | |
by scottknight (Novice) on Nov 29, 2004 at 23:39 UTC |