[MKDoc-commit] Provide an empty $body if undef.

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Wed Feb 2 18:42:45 GMT 2005


Log Message:
-----------
Provide an empty $body if undef.  Don't deliver Etag's on HEAD requests as
old behaviour gave the same Etag for all documents.

Modified Files:
--------------
    MKDoc-Apache_Cache/lib/MKDoc:
        Apache_Cache.pm

-------------- next part --------------
Index: Apache_Cache.pm
===================================================================
RCS file: /var/spool/cvs/MKDoc-Apache_Cache/lib/MKDoc/Apache_Cache.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -Llib/MKDoc/Apache_Cache.pm -Llib/MKDoc/Apache_Cache.pm -u -r1.14 -r1.15
--- lib/MKDoc/Apache_Cache.pm
+++ lib/MKDoc/Apache_Cache.pm
@@ -89,6 +89,7 @@
     lc $ENV{'HTTP_ACCEPT_ENCODING'} !~ /gzip/ and do {
 
         my ($headers, $body) = split /\r?\n\r?\n/, $data, 2;
+        $body = '' unless ($body);
         $headers = join "\r\n",
                    grep !/content-length\:/i,
                    grep !/content-encoding\:/i,
@@ -102,6 +103,7 @@
 
     $ENV{REQUEST_METHOD} =~ /HEAD/i and do {
         $data =~ s/\r?\ncontent-length\:.*//i;
+        $data =~ s/\r?\netag\:.*//i;
     };
 
     $r->print ($data);
@@ -220,6 +222,7 @@
 {
     my $buf = shift;
     my ($headers, $body) = split /\r?\n\r?\n/, $buf, 2;
+    $body = '' unless ($body);
     my @o = ();
 
     # Figure out some kind of content_type
@@ -237,7 +240,7 @@
     };
 
     # Compute ETag
-    push @o, "ETag: " . Digest::MD5::md5_hex ($body);
+    push @o, "ETag: " . Digest::MD5::md5_hex ($body) if ($body);
 
     # Compute Content-Length
     push @o, "Content-Length: " . length ($body) if ($body);


More information about the MKDoc-commit mailing list