Add Content-Length header to thumb.php error responses
authorOri Livneh <ori@wikimedia.org>
Mon, 6 Jul 2015 20:49:45 +0000 (13:49 -0700)
committerOri.livneh <ori@wikimedia.org>
Mon, 6 Jul 2015 20:52:43 +0000 (20:52 +0000)
Without the Content-Length header, the response is sent with Transfer-Encoding:
Chunked, which is somehow mangled by mod_fastcgi. Varnish then claims the
response is malformed and declines to process it, sending the client a 503
instead.

Change-Id: I977387bf3e039926df58e3e5a14d0d0bd55201c4

thumb.php

index c4e690e..b530bb5 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -570,7 +570,7 @@ function wfThumbError( $status, $msg ) {
        } else {
                $debug = '';
        }
-       echo <<<EOT
+       $content = <<<EOT
 <!DOCTYPE html>
 <html><head>
 <meta charset="UTF-8" />
@@ -586,4 +586,6 @@ $debug
 </html>
 
 EOT;
+       header( 'Content-Length: ' . strlen( $content ) );
+       echo $content;
 }