[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#475426: Incorrect Content-Length and Content-Type with "Premature end of script headers" error page



Package: apache2
Version: 2.2.3-4+etch4

If a CGI script dies without printing any headers to STDOUT, Apache returns a "500 Internal Server Error" page and logs "Premature end of script headers".

However, the error page returned to the visitor has incorrect headers. It looks like this:

  HTTP/1.1 500 Internal Server Error
  Date: Thu, 10 Apr 2008 17:21:05 GMT
  Server: Apache/2.2.3 (Debian) mod_python/3.2.10 [etc.]
  Content-Length: 0
  Connection: close
  Content-Type: text/plain; charset=UTF-8

  <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  <html><head>
  <title>500 Internal Server Error</title>
  </head><body>
  <h1>Internal Server Error</h1>
  <p>The server encountered an internal error or
  [etc.]

The "Content-Length: 0" and "Content-Type: text/plain" headers are both wrong. These incorrect headers make some browsers (e.g., Konqueror) fail to display the HTML content of the error page.

For comparison, Apache 2.0 sent the correct Content-Length and used the correct "Content-Type: text/html" header.

This is easy to duplicate by creating a CGI script that contains nothing more than:

  #!/bin/sh
  exit 0;

Thanks!

--
Robert L Mathews



Reply to: