[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Re: IO to a web site.
- Subject: [ale] Re: IO to a web site.
- From: eric at afaik.us (Eric Anderson)
- Date: Mon Nov 15 09:15:23 2004
- In-reply-to: <[email protected]>
- References: <[email protected]>
Christopher Fowler wrote:
> I expected this to be more line by line basis but google is not
> terminated the connection after the page is spit out. Also I do not
> seem to get the whole page and am stuck in the while loop.
[...snipped...]
> my $string = "GET / HTTP/1.1\r\n\r\n";
>
> my $s = IO::Socket::INET->new(PeerAddr => 'www.google.com',
> PeerPort => 80, Proto => 'tcp') or die "$!\n";
>
>
> print $s $string;
> $s->flush();
> while(<$s>) {
> print $_;
> STDOUT->flush();
Just a guess here but doesn't HTTP 1.1 support persistent connections
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1)?
Therefore if you want to have it close the connection after the response
is given you will need to send the connection token "close" in the
Connection Header. Or you could simply use HTTP 1.0. The default
behavior for HTTP 1.0 is to close the connection after every request.
Give that a try and see if it gets you any further.
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature