php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70189 CLI server sends empty Content-Type when default_mimetype=''
Submitted: 2015-08-03 13:41 UTC Modified: 2015-08-03 14:47 UTC
Votes:5
Avg. Score:3.2 ± 1.3
Reproduced:4 of 5 (80.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: bugs dot php dot net at majkl578 dot cz Assigned:
Status: Closed Package: *Web Server problem
PHP Version: 7.0.0beta2 OS: *
Private report: No CVE-ID: None
 [2015-08-03 13:41 UTC] bugs dot php dot net at majkl578 dot cz
Description:
------------
When the configuration directive default_mimetype is not set (empty), the CLI server sends an empty Content-Type header, which violates RFC 2616.

FPM, for example, does not send the header at all (expected behavior).

Test script:
---------------
<?php

ini_set('default_mimetype', '');

Expected result:
----------------
$ curl -I http://example.com/test.php
HTTP/1.1 200 OK
Host: example.com
Connection: close
X-Powered-By: PHP/7.0.0beta2

Actual result:
--------------
$ curl -I http://example.com/test.php
HTTP/1.1 200 OK
Host: example.com
Connection: close
X-Powered-By: PHP/7.0.0beta2
Content-type:

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-03 14:47 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Built-in web server +Package: *Web Server problem -Operating System: Linux +Operating System: *
 [2015-08-03 14:47 UTC] cmb@php.net
Confirmed for PHP 5.6.11 as well. That appears to be a general
SAPI issue[1]. If get_default_content_type() returns an empty
string, the Content-Type header is send nonetheless, what is wrong
anyway.

RFC 7231 states[2]:

| A sender that generates a message containing a payload body
| SHOULD generate a Content-Type header field in that message
| unless the intended media type of the enclosed representation is
| unknown to the sender.

So yes, not sending any Content-Type header seems to be reasonable
in this case.

[1] <https://github.com/php/php-src/blob/php-7.0.0beta2/main/SAPI.c#L862-L873>
[2] <http://tools.ietf.org/html/rfc7231#section-3.1.1.5>
 [2015-09-19 18:25 UTC] j dot tvr at centrum dot cz
This issue is still valid with PHP 7.0.0-RC3. This fix should be very simple and straightforward, could someone look into it?
 [2016-03-11 10:42 UTC] jakub at zalas dot pl
Confirmed this is also an issue on PHP 5.5.30.
 [2016-03-27 05:51 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=28f66763a436066d51b21dcf9d6ac3f5a0b33df7
Log: fix #70189 (SAPI sends empty Content-Type when default_mimetype is empty)
 [2016-03-27 05:51 UTC] krakjoe@php.net
-Status: Verified +Status: Closed
 [2016-03-27 05:52 UTC] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=28f66763a436066d51b21dcf9d6ac3f5a0b33df7
Log: fix #70189 (SAPI sends empty Content-Type when default_mimetype is empty)
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=28f66763a436066d51b21dcf9d6ac3f5a0b33df7
Log: fix #70189 (SAPI sends empty Content-Type when default_mimetype is empty)
 [2018-10-14 19:55 UTC] zaid at developerhub dot io
This issue still exists with PHP7.2.8
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon May 20 12:01:26 2019 UTC