I posted this on the talk page for the API. Trying to find an answer.
I did try with 16.5, but still the same error, it is reporting a doubled Content-Length. Where in the code is the header formed for content length? Or is it relying on server?
Doubled Content-Length in HTTP Header
MediaWiki version: 16.0 - also tried 16.5
PHP version: 5.2.17 (cgi)
MySQL version: 5.0.91-log
URL: www.isogg.org/w/api.php
I am trying to track down a bug in the api which is causing a double content-length in the header. This is causing a lot of issues with a python bot. Here is the report from web-sniffer showing the content of the api.php call from this wiki. All other pages when called, i.e. the Main page, etc. only report 1 content-length. Is the api forcing the headers? Why is doubling only the one?
Status: HTTP/1.1 200 OK
Date: Mon, 30 Jan 2012 14:31:25 GMT
Content-Type: text/html; charset=utf-8 Connection: close
Server: Nginx / Varnish
X-Powered-By: PHP/5.2.17
MediaWiki-API-Error: help
Cache-Control: private
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Length: 16656
Content-Length: 16656
As you can see this is a Nginx server. On an Apache server with 16.0, only one content-length is sent. Could that be the issue and how do I solve it? Thanks.
Tom
On 31/01/12 03:37, Tom Hutchison wrote:
As you can see this is a Nginx server. On an Apache server with 16.0, only one content-length is sent. Could that be the issue and how do I solve it? Thanks.
Tom
I suspect that may be a php bug (the difference in Apache could lie in the SAPI or in Apache cleaning up the output).
What's the number of Content-Lengths of these php scripts ? <?php header("Content-Length: 6"); echo "Hello\n";
<?php header("Content-Length: 6"); header("Content-Length: 6"); echo "Hello\n";
What's the number of Content-Lengths of these php scripts ? <?php header("Content-Length: 6"); echo "Hello\n";
2 content lengths shown.
<?php header("Content-Length: 6"); header("Content-Length: 6"); echo "Hello\n";
2 content lengths shown.
For the heck of it I used this:
<?php header("Content-Length: 6"); header("Content-Length: 6"); header("Content-Length: 6"); echo "Hello\n";
Still only 2 content lengths shown.
One must be served automatically and appended to the header, and the others are "merged" into one.
I ran web-sniffer with just a header request on the 3 header set above and got:
Content-Length: 6 Content-Length: 0
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
On 31/01/12 17:25, Tom Hutchison wrote:
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi. I suspect the MediaWiki one was added in wfDoContentLength() at includes/OutputHandler.php Ironically, it was added in order to improve compatibilty with squid. You could comment that line, but the bug should be fixed at ngninx.
On Tue, Jan 31, 2012 at 4:32 PM, Platonides platonides@gmail.com wrote:
On 31/01/12 17:25, Tom Hutchison wrote:
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
On Tue, Jan 31, 2012 at 5:11 PM, OQ overlordq@gmail.com wrote:
On Tue, Jan 31, 2012 at 4:32 PM, Platonides platonides@gmail.com wrote:
On 31/01/12 17:25, Tom Hutchison wrote:
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
And by zero I meant 1.
HTTP/1.1 200 OK Server: nginx/1.1.14 Date: Tue, 31 Jan 2012 23:12:14 GMT Content-Type: text/html Content-Length: 6 Connection: close X-Powered-By: PHP/5.3.9-1
This wiki is on a shared host. I don't have root access, not even a jailed shell. I don't think I can control that with php.ini, although I do have php.ini access.
Tom Sent from my iPhone
On Jan 31, 2012, at 6:13 PM, OQ overlordq@gmail.com wrote:
On Tue, Jan 31, 2012 at 5:11 PM, OQ overlordq@gmail.com wrote:
On Tue, Jan 31, 2012 at 4:32 PM, Platonides platonides@gmail.com wrote:
On 31/01/12 17:25, Tom Hutchison wrote:
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
And by zero I meant 1.
HTTP/1.1 200 OK Server: nginx/1.1.14 Date: Tue, 31 Jan 2012 23:12:14 GMT Content-Type: text/html Content-Length: 6 Connection: close X-Powered-By: PHP/5.3.9-1
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
On 01/02/12 00:13, OQ wrote:
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
And by zero I meant 1.
HTTP/1.1 200 OK Server: nginx/1.1.14 Date: Tue, 31 Jan 2012 23:12:14 GMT Content-Type: text/html Content-Length: 6 Connection: close X-Powered-By: PHP/5.3.9-1
Interesting. Are you also running php as cgi? You're running a more recent php (5.3.9-1 vs 5.2.17), so it could also have been a fixed php bug.
On Wed, Feb 1, 2012 at 12:52 PM, Platonides platonides@gmail.com wrote:
On 01/02/12 00:13, OQ wrote:
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
And by zero I meant 1.
HTTP/1.1 200 OK Server: nginx/1.1.14 Date: Tue, 31 Jan 2012 23:12:14 GMT Content-Type: text/html Content-Length: 6 Connection: close X-Powered-By: PHP/5.3.9-1
Interesting. Are you also running php as cgi? You're running a more recent php (5.3.9-1 vs 5.2.17), so it could also have been a fixed php bug.
As FastCGI with php5-fpm.
Wow, 6 days later and the host is trying to tell me they do it to prevent Cross-scripting, et al attacks. Did you ever heard such a line?
-----Original Message----- From: mediawiki-api-bounces@lists.wikimedia.org [mailto:mediawiki-api-bounces@lists.wikimedia.org] On Behalf Of OQ Sent: Wednesday, February 01, 2012 2:51 PM To: MediaWiki API announcements & discussion Subject: Re: [Mediawiki-api] Content-Length being written twice in HTTPHeader
On Wed, Feb 1, 2012 at 12:52 PM, Platonides platonides@gmail.com wrote:
On 01/02/12 00:13, OQ wrote:
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi.
I'd definately check your configuration, mine send 0 content-length headers.
And by zero I meant 1.
HTTP/1.1 200 OK Server: nginx/1.1.14 Date: Tue, 31 Jan 2012 23:12:14 GMT Content-Type: text/html Content-Length: 6 Connection: close X-Powered-By: PHP/5.3.9-1
Interesting. Are you also running php as cgi? You're running a more recent php (5.3.9-1 vs 5.2.17), so it could also have been a fixed php bug.
As FastCGI with php5-fpm.
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
I did solve the issue 1/2 way.
I ended up having to replace content length with page length in that function. Commenting out the whole function caused all kinds of issues and basically crashed the site. So apparently that function is supplying the content length field for actual pages too.
I did open a support ticket at the host. I think I blew a gasket there because I am now on my fourth reply saying please wait while we upgrade your question to a higher tech.
Tom Sent from my iPhone
On Jan 31, 2012, at 5:32 PM, Platonides platonides@gmail.com wrote:
On 31/01/12 17:25, Tom Hutchison wrote:
Same for all of them, whether there is 2, 3 or 4 header sets in the php script.
The only time the Content-Length vanished from the header was when I requested just the header without setting the Content-Length.
So the question becomes, since this server is forcing the Content-Length to be appended to the header, how do I stop the API from writing the extra Content-Length to the header?
Thanks for your help! Tom
Looks like a nginx bug. They are always adding a Content-Length. Even if one was already provided by the cgi. I suspect the MediaWiki one was added in wfDoContentLength() at includes/OutputHandler.php Ironically, it was added in order to improve compatibilty with squid. You could comment that line, but the bug should be fixed at ngninx.
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
mediawiki-api@lists.wikimedia.org