|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76039 header() not sending headers on empty output
Submitted: 2018-03-01 15:26 UTC Modified: -
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: Assigned:
Status: Open Package: Apache2 related
PHP Version: 7.0.28 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
46 - 12 = ?
Subscribe to this entry?

 [2018-03-01 15:26 UTC]
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";

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
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


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri May 14 10:01:23 2021 UTC