Bug #76039 [Opn->Fbk]: header() not sending headers on empty output

From: Date: Tue, 02 Nov 2021 17:11:09 +0000
Subject: Bug #76039 [Opn->Fbk]: header() not sending headers on empty output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237516@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76039&edit=1

 ID:                 76039
 Updated by:         cmb@php.net
 Reported by:        yunosh@php.net
 Summary:            header() not sending headers on empty output
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Apache2 related
 Operating System:   Linux
 PHP Version:        7.0.28
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I cannot reproduce that with PHP-7.4.  Is this still an issue for
you with any of the actively supported PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>


Previous Comments:
------------------------------------------------------------------------
[2018-03-01 15:26:52] yunosh@php.net

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 this bug report at https://bugs.php.net/bug.php?id=76039&edit=1


Thread (3 messages)

« previous php.bugs (#237516) next »