Is it possible to set custom status message (in utf-8) in http status header?

时间:2016-04-07 10:29:20

标签: php apache http

I want to change http status header with my own status message. For example, change HTTP/1.1 200 OK to HTTP/1.1 200 custom status message in utf-8. To do it, I send some headers with php:

Content-Type: text/html; charset=UTF-8
HTTP/1.1 200 custom status message in utf-8

But in Chrome developer tools I see status message in wrong encoding, for example Status Code:200 УпÑ! ЧÑо-Ñо. Is it possible to fix this?

2 个答案:

答案 0 :(得分:4)

(a) the encoding is undefined, so it's not worth trying non-ASCII, furthermore, (b) the reason phrase does not exist anymore in in HTTP/2.

答案 1 :(得分:0)

You just used below line to change HTTP header status code and messages

$msg = "custom status message";

header("Status: 200");
header("HTTP/1.1 200 ".$msg);