Headers not being sent correctly

matt

Active Member
#1

mistwang

LiteSpeed Staff
#2
Hi Matt,

Thank you for the bug report.

Did some investigation with lynx, when I do "lynx --mime_header http://matt.wordpress.com/feed/", the header looks like:

Code:
HTTP/1.0 200 OK
X-totalblogs: 14127
X-rootblog: http://wordpress.com/
X-created-on: 2005-07-20 19:50:09
x-db: 207.7.108.198
X-Pingback: http://matt.wordpress.com/xmlrpc.php
Last-Modified: Tue, 25 Oct 2005 23:26:01 GMT
ETag: "deca730f620152cfa102d56d2237361e"
OK
Content-type: text/xml; charset=UTF-8
Server: LiteSpeed
Date: Mon, 31 Oct 2005 00:33:04 GMT
Connection: close

<?xml version="1.0" encoding="UTF-8"?>

...
There is an extra "OK" below ETag header, I will try to duplicate this with PHP's header() function, it will be great if you can give me an example.

Thanks,
George
 

matt

Active Member
#3
Here is a list of header calls that could have been triggered on that page:

Code:
wp-includes/wpmu-functions.php:301:     header( "X-totalblogs: " . get_blog_count() );
wp-includes/wpmu-functions.php:302:     header( "X-rootblog: http://" . $current_site->domain . $current_site->path );
wp-includes/wpmu-functions.php:303:     header( "X-created-on: " . $current_blog->registered );
wp-includes/wpmu-functions.php:306:             header( "X-wpmu-date: $WPMU_date" );
wp-includes/wp-db.php:504:      header( 'Content-Type: text/html; charset=utf-8');
wp-includes/pluggable-functions.php:157:                header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
wp-includes/pluggable-functions.php:170:                header("Refresh: 0;url=$location");
wp-includes/pluggable-functions.php:172:                header("Location: $location");
wp-includes/classes.php:1495:           @header('X-Pingback: '. get_bloginfo('pingback_url'));
wp-includes/classes.php:1497:                   status_header( 404 );
wp-includes/classes.php:1499:                   @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
wp-includes/classes.php:1507:                   @header("Last-Modified: $wp_last_modified");
wp-includes/classes.php:1508:                   @header("ETag: $wp_etag");
wp-includes/classes.php:1524:                           status_header( 304 );
wp-includes/classes.php:1587:                   status_header( 404 );
wp-includes/classes.php:1589:                   status_header( 200 );
wp-includes/functions.php:2059:         @header("Status: $header $text");
wp-includes/functions.php:2062:                 @header($text, TRUE, $header);
wp-includes/functions.php:2064:                 @header("HTTP/1.x $header $text");
wp-includes/functions.php:2069: @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
wp-includes/functions.php:2070: @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
wp-includes/functions.php:2071: @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
wp-includes/functions.php:2072: @ header('Pragma: no-cache');
wp-rss2.php:8:header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
I suspect it might be related to the status header function, which is this:

Code:
function status_header( $header ) {
	if ( 200 == $header )
		$text = 'OK';
	elseif ( 301 == $header )
		$text = 'Moved Permanently';
	elseif ( 302 == $header )
		$text = 'Moved Temporarily';
	elseif ( 304 == $header )
		$text = 'Not Modified';
	elseif ( 404 == $header )
		$text = 'Not Found';
	elseif ( 410 == $header )
		$text = 'Gone';

	if ( preg_match('/cgi/',php_sapi_name()) ) {
		@header("Status: $header $text");
	} else {
		if ( version_compare(phpversion(), '4.3.0', '>=') )
			@header($text, TRUE, $header);
		else
			@header("HTTP/1.x $header $text");
	}
}
Thanks for your help with this.
 

mistwang

LiteSpeed Staff
#5
Thank you for the update.

The issue is that,
Code:
@header("OK", TRUE, 200);
is used when call "status_header( 200 )", and this will add a header only contains "OK\n" in the response header, then LSWS just append this line to the response header list when receive this line.

We add some validation check to remove those kind of header unless it starts with a white space character (for multi line response header) in next release.

I might be wrong as I am not a PHP coder, I think the header generation code should use the CGI style "Status:..." or HTTP style "HTTP/1.x ...", not only the status text, as it is not a valid header. :)
 
Top