Php Content-Type header issue


#1

There is an issue with PHP Content-Type headers.

when header() function is NOT USED, php returns 2 headers:
1: Content-Type: text/html; charset=UTF-8
2: Content-Type: text/html

when header('Content-Type: text/html') is used, php returns 2 headers:
1: Content-Type: text/html; charset=UTF-8
2: Content-Type: text/html; charset=UTF-8

when header('Content-Type: text/event-stream') is used, php returns 2 headers:
1: Content-Type: text/event-stream; charset=UTF-8
2: Content-Type: text/event-stream; charset=UTF-8

when header('Content-Type: application/json') is used, php returns ONLY 1 (as ecpected) headers:
1: Content-Type: application/json

WHAT WORKS AS EXPECTED:

When header('Content-Type: application/json') is used:
correctly returned: Content-Type: application/json

WHAT IS EXPECTED:

When no headers set:
expected: Content-Type: text/html

When header('Content-Type: text/html') is used:
expected: Content-Type: text/html

When header('Content-Type: text/html; charset=UTF-8') is used:
expected: Content-Type: text/html; charset=UTF-8

When header('Content-Type: text/event-stream') is used:
expected: Content-Type: text/event-stream

I hope I am clear enough.


#2

We’ll check that; thanks for the report!


#3

If this is any relevant, I noticed above issue when I was trying out javascript’s EventSource. It ended up with an error such as
EventSource's response has a MIME type ("text/event-stream;charset=UTF-8") that is not "text/event-stream". Aborting the connection.

Though I surely remember that header('Content-Type: text/event-stream'); worked as expected in an older version (at least before v2018) of ExeOutput4PHP.


#4

@gdgsupport any updates? Headers were correct in previous versions of ExeOutput, this should not be that hard?


#5

Initial research indicates a problem with the CEF updated implementation. We’re waiting for a fix.


#6

As @gdgsupport mentioned in email, the problem was due to a setting in php.ini.

Replacing default-charset="UTF-8" with default-charset="" solved the extra charset=UTF-8 issue!

About the double Content-Type headers being returned, ExeOutput Team will publish a fix in upcoming update, I guess.

Thank you for the resolution, @gdgsupport!