Bug #76039 [NEW]: header() not sending headers on empty output

From: Date: Thu, 01 Mar 2018 15:26:54 +0000
Subject: Bug #76039 [NEW]: header() not sending headers on empty output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214168@lists.php.net to get a copy of this message
From:             yunosh
Operating system: Linux
PHP version:      7.0.28
Package:          Apache2 related
Bug Type:         Bug
Bug description:header() not sending headers on empty output

Description:
------------
Not sure if other SAPIs are affected too, but at least I could not
reproduce this with PHP's builtin server.

If sending HTTP headers with the header() method, these headers are no
longer sent if the HTTP response body is empty. This can be worked
around by flush()ing manually.

PHP 7.0.25

Test script:
---------------
header('X-Foo: bar');
// flush();
// echo "foo";
exit;

Expected result:
----------------
HTTP/1.1 200 OK
Date: Thu, 01 Mar 2018 15:24:28 GMT
Server: Apache/2.4.18 (Ubuntu)
X-Foo: bar
Vary: Accept-Encoding
X-Mod-Pagespeed: 1.13.35.2-0
Cache-Control: max-age=0, no-cache
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8


Actual result:
--------------
HTTP/1.1 200 OK
Date: Thu, 01 Mar 2018 15:24:12 GMT
Server: Apache/2.4.18 (Ubuntu)
Cache-Control: max-age=0, no-cache
Content-Length: 0
Content-Type: text/html; charset=UTF-8


-- 
Edit bug report at https://bugs.php.net/bug.php?id=76039&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76039&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76039&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76039&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76039&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76039&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76039&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76039&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76039&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76039&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76039&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76039&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76039&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76039&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76039&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76039&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76039&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76039&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76039&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76039&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76039&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#214168) next »