HTTP Header (using IO::Socket) 
Author Message
 HTTP Header (using IO::Socket)

I got the following code to work fine for regular http requests.
Howevr, now I want to make and HTTP request for a page that is password
protected.  I was instructed to add: "Authorization: Basic
base64-encoded-string" to the request, where "base64-encoded-string" is
the base64 of "username:password".  I still get an access denied,
however.  Below is the code I am using.

Thank your for any help you can offer.

-Brandon

--------CODE----------

print "Host: $host<BR>\n";
print "Document: $document<BR>\n";
use IO::Socket;

 $remote = IO::Socket::INET->new( Proto => "tcp",
 PeerAddr => $host,
 PeerPort => "http(80)",
 );
 unless ($remote)
 {
  die "cannot connect to ftp daemon on $host"
 }
 $remote->autoflush(1);
 print "<BR>Making request...<BR>";
# print $remote "GET $document HTTP/1.0\n\n";
 print $remote "GET $document HTTP/1.0 Authorization: Basic
base64-encoded-string\n\n";

 while ( <$remote> ) { print }
 close $remote;



Thu, 25 Jan 2001 03:00:00 GMT  
 HTTP Header (using IO::Socket)

Brandon> I got the following code to work fine for regular http
Brandon> requests.  Howevr, now I want to make and HTTP request for a
Brandon> page that is password protected.  I was instructed to add:
Brandon> "Authorization: Basic base64-encoded-string" to the request,
Brandon> where "base64-encoded-string" is the base64 of
Brandon> "username:password".  I still get an access denied, however.
Brandon> Below is the code I am using.

Brandon> Thank your for any help you can offer.

Yes.  Stop reinventing LWP.  Go get LWP.  LWP is your friend.
It's bloated for a reason -- it does sooooooo much!

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me



Thu, 25 Jan 2001 03:00:00 GMT  
 HTTP Header (using IO::Socket)
Problem solved.  I am now using LWP.
Quote:

> I got the following code to work fine for regular http requests.
> Howevr, now I want to make and HTTP request for a page that is password
> protected.  I was instructed to add: "Authorization: Basic
> base64-encoded-string" to the request, where "base64-encoded-string" is
> the base64 of "username:password".  I still get an access denied,
> however.  Below is the code I am using.

> Thank your for any help you can offer.

> -Brandon

> --------CODE----------

> print "Host: $host<BR>\n";
> print "Document: $document<BR>\n";
> use IO::Socket;

>  $remote = IO::Socket::INET->new( Proto => "tcp",
>  PeerAddr => $host,
>  PeerPort => "http(80)",
>  );
>  unless ($remote)
>  {
>   die "cannot connect to ftp daemon on $host"
>  }
>  $remote->autoflush(1);
>  print "<BR>Making request...<BR>";
> # print $remote "GET $document HTTP/1.0\n\n";
>  print $remote "GET $document HTTP/1.0 Authorization: Basic
> base64-encoded-string\n\n";

>  while ( <$remote> ) { print }
>  close $remote;



Thu, 25 Jan 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Time out with perl Socket using IO::Socket

2. Help with creating UDP sockets using IO::Socket

3. Creating udp sockets using IO::Socket

4. mod_perl problems - core dump using Socket or IO:Socket in startup.pl

5. mod_perl problems - core dump using Socket or IO:Socket in startup.pl

6. Socket communication using IO::Socket (sending/receiving)

7. Proper way to close an IO::Socket or IO::Socket::INET

8. IO::Socket, HTTP POST vs. GET

9. IO::Socket, IO::Select, and buffered/unbuffered IO

10. problem using HTTP::Headers Help!

11. Using Window-target in HTTP header not outputting to correct frame in Internet Explorer

12. Creating the http-header without using CGI.pm

 

 
Powered by phpBB® Forum Software