Bug #73936 [NEW]: Certain special header() calls wrongly prevent connection from closing
| From: | markamery at btinternet dot com | Date: | Sat, 14 Jan 2017 18:38:57 +0000 |
| Subject: | Bug #73936 [NEW]: Certain special header() calls wrongly prevent connection from closing | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-206622@lists.php.net to get a copy of this message | ||
From: markamery at btinternet dot com
Operating system: Ubuntu
PHP version: Irrelevant
Package: Apache2 related
Bug Type: Bug
Bug description:Certain special header() calls wrongly prevent connection from closing
Description:
------------
Running under mod_php, calling
header('HTTP/1.1 200 OK');
seems to prevent the connection from being closed once the PHP script
finishes. This can be demonstrated by, for instance, hitting the script
with ab (the Apache benchmark tool), which (unlike most HTTP clients,
including browsers) only considers a request to have finished once the
connection is closed, rather than when Content-Length bytes have been
received. http://stackoverflow.com/q/34367115/1709587
describes this
case in more detail.
Bizarrely,
header('http/1.1 200 OK');
does not have the same effect, despite producing a
character-for-character identical HTTP response (as can be observed with
curl -i --raw).
Test script:
---------------
<?php
header('HTTP/1.1 200 OK');
Expected result:
----------------
Unless Connection: keep-alive is specified in the request, the
connection should close once the PHP script finishes. In particular, the
behaviour should be identical to other calls with the same meaning,
like
<?php
http_response_code(200);
or
<?php
header('http/1.1 200 OK')
Actual result:
--------------
The connection does not close, and the alternate scripts suggested above
have different behaviours to the test script.
--
Edit bug report at https://bugs.php.net/bug.php?id=73936&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73936&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73936&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73936&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=73936&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=73936&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=73936&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=73936&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=73936&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=73936&r=support
Expected behavior: https://bugs.php.net/fix.php?id=73936&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=73936&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=73936&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=73936&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73936&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=73936&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=73936&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=73936&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=73936&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=73936&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=73936&r=mysqlcfg