Subject: | Failure to send CRLF after HTTP header fields |
Currently, HTTP::Server::Simple::Static sends "\n" to separate header
fields. Section 4.1 Message Types of RFC 2616 states that CRLF should
separate header fields.
The attached patch uses the approach recommended in perlport(1) to
accomplish this.
The patch also adds the "use bytes" pragma to ensure Content-Length
contains the number of bytes in the response body, not the number of
characters.
Subject: | HTTP-Server-Simple-Static.patch |
diff -ruN HTTP-Server-Simple-Static-0.03.old/lib/HTTP/Server/Simple/Static.pm HTTP-Server-Simple-Static-0.03/lib/HTTP/Server/Simple/Static.pm
--- HTTP-Server-Simple-Static-0.03.old/lib/HTTP/Server/Simple/Static.pm Tue Jun 13 11:02:25 2006
+++ HTTP-Server-Simple-Static-0.03/lib/HTTP/Server/Simple/Static.pm Tue Jul 18 11:33:11 2006
@@ -38,9 +38,10 @@
my $mime = ($mimeobj ? $mimeobj->type :
$magic->checktype_contents($content));
- print "HTTP/1.1 200 OK\n";
- print "Content-type: " . $mime . "\n";
- print "Content-length: " . length($content) . "\n\n";
+ use bytes; # Content-Length in bytes, not characters
+ print "HTTP/1.1 200 OK\015\012";
+ print "Content-type: " . $mime . "\015\012";
+ print "Content-length: " . length($content) . "\015\012\015\012";
print $content;
return 1;
}