Set content type without charset

Viewed 1191

I'm trying to set the header Content-Type to text/html, but without specifying the charset. If I run the following code:

header('Content-Type: text/html');
var_dump(headers_list());

I get the following output:

['Content-type: text/html;charset=UTF-8']

The charset parameter is added automatically! And Content-Type is changed to Content-type. The same happens with any content type with the type text. For example Content-Type: text/foobar becomes Content-type: text/foobar;charset=UTF-8.

If I specify any additional parameters, they are kept. For example Content-Type: text/foobar; param=value becomes Content-type: text/foobar; param=value;charset=UTF-8.

If I specify the charset parameter, the header is not changed. For example Content-Type: text/html; charset=ISO-8859-1 stays Content-Type: text/html; charset=ISO-8859-1. In this case, the header field name is not changed from Content-Type to Content-type either.

If I specify a content type that has a type other than text, the header is not changed. For example Content-Type: foo/bar stays the same.

Is it not possible to specify a text-based content type without the charset parameter? I'm using PHP 7.1.1 and Apache 2.4.26.

0 Answers
Related