php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55341 Problem with headers longer than 4008 under FPM
Submitted: 2011-08-02 00:11 UTC Modified: 2011-08-02 01:14 UTC
From: php-bugs at majkl578 dot cz Assigned: fat (profile)
Status: Not a bug Package: FPM related
PHP Version: 5.4SVN-2011-08-01 (snap) OS: Linux Debian Sid
Private report: No CVE-ID: None
 [2011-08-02 00:11 UTC] php-bugs at majkl578 dot cz
Description:
------------
There is a problem when headers sent from a script are longer than 4008 (see the test sript below). I'm currently using FPM with nginx 1.0.5.

If headers are longer than 4008, this happens:
for 4008, everything is OK,
for 4009, no output is displayed,
for 4010+, HTTP error 502 is returned.

Similar problem has been verified under PHP 5.3.5 with different boundaries:
4012 is OK,
4013 is OK, but with no output,
4014 gives 502.

Test script:
---------------
OK:

header(str_repeat('x', 4008));
echo 'foo';

--------------------------------
OK, but no output:

header(str_repeat('x', 4009));
echo 'foo';

--------------------------------
HTTP error 502:

header(str_repeat('x', 4010)); //or anything higher
echo 'foo';

--------------------------------
OK:

header(str_repeat('x', 2000));
header(str_repeat('y', 2006));
echo 'foo';
--------------------------------
OK, no output:

header(str_repeat('x', 2000));
header(str_repeat('y', 2007));
echo 'foo';
--------------------------------
502:

header(str_repeat('x', 2000));
header(str_repeat('y', 2008));
echo 'foo';

Expected result:
----------------
foo


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-02 00:33 UTC] fat@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: fat
 [2011-08-02 01:14 UTC] fat@php.net
-Status: Assigned +Status: Bogus
 [2011-08-02 01:14 UTC] fat@php.net
To me this is not related to PHP nor FPM but to nginx. 

by default nginx uses 4k or 8k buffers for fastcgi. you must have an error in your nginx log file, something 
like:

upstream sent too big header while reading response header from upstream

You should play with "fastcgi_buffer_size" and "fastcgi_buffers" in your nginx.conf. See 
http://wiki.nginx.org/HttpFcgiModule#fastcgi_buffers for more details.

I've been able to reproduce and correct the problem this way on my dev machine.

If you really think this is another problem, feel free to reopen this bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 12:01:30 2024 UTC