Page MenuHomePhabricator

When page not found, sends malformed HTTP/1.x instead of HTTP/1.1 in header of response
Closed, ResolvedPublic

Description

Author: scott

Description:
When using suPHP and visiting a non existent entry it generates a malformed header error because its defining HTTP/1.x

The exact error is,

malformed header from script. Bad header=HTTP/1.x 404 Not Found: index.php

The offending line is

includes/Article.php

$wgRequest->response()->header( "HTTP/1.x 404 Not Found" );

This should be

$wgRequest->response()->header( "HTTP/1.1 404 Not Found" );

The same also applies to

includes/WebStart.php

Which has the same problem when defining an 500, Internal Server Error.

Here is the diff to fix the problem,

diff -Naur mediawiki-1.16.2-original/includes/Article.php mediawiki-1.16.2/includes/Article.php

  • mediawiki-1.16.2-original/includes/Article.php 2011-01-04 06:15:54.000000000 +0000

+++ mediawiki-1.16.2/includes/Article.php 2011-03-24 03:11:42.000000000 +0000
@@ -1278,7 +1278,7 @@

		if ( !$this->hasViewableContent() ) {
			// If there's no backing content, send a 404 Not Found
			// for better machine handling of broken links.
  • $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );

+ $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );

		}
		$wgOut->addWikiText( $text );
	}

diff -Naur mediawiki-1.16.2-original/includes/WebStart.php mediawiki-1.16.2/includes/WebStart.php

  • mediawiki-1.16.2-original/includes/WebStart.php 2009-05-07 19:30:26.000000000 +0100

+++ mediawiki-1.16.2/includes/WebStart.php 2011-03-24 03:11:50.000000000 +0000
@@ -30,7 +30,7 @@

	);
	foreach ( $_REQUEST as $name => $value ) {
		if( in_array( $name, $verboten ) ) {
  • header( "HTTP/1.x 500 Internal Server Error" );

+ header( "HTTP/1.1 500 Internal Server Error" );

			echo "register_globals security paranoia: trying to overwrite superglobals, aborting.";
			die( -1 );
		}

Version: unspecified
Severity: trivial

Details

Reference
bz28214

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:31 PM
bzimport set Reference to bz28214.
bzimport added a subscriber: Unknown Object (MLST).

I always thought the x got magically replaced with the relevant version number.

scott wrote:

I have never seen it defined as 1.x, looking at other parts of the system it also defines 1.1. Those 2 locations seem to be the only ones which define as 1.x