in reply to Re^2: IO::Socket Get Headers
in thread IO::Socket Get Headers
If you check the spec, you'll notice HTTP header lines are terminated by CRLF. Your code checks for only LF. 015 is the octal value for CR, 012 is the octal value for LF. ("\r\n" isn't good cause they're not always CR and LF.)
You can tell you received two CRLF in a row when reading a line at a time by checking for a blank line.
my @headers; { local $/ = "\015\012"; while (<IN>) { chomp; last if $_ eq ''; push(@headers, $_); } } my $request_line = shift(@headers);
That handles HTTP/1.0 and HTTP/1.1 requests, but I don't know about HTTP/0.9 requests.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: IO::Socket Get Headers
by JoeJaz (Monk) on Oct 04, 2004 at 22:26 UTC | |
by ikegami (Patriarch) on Oct 04, 2004 at 22:34 UTC | |
by JoeJaz (Monk) on Oct 05, 2004 at 01:02 UTC |