Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

http

php

apache

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?

like image 503
Evgeniy Avatar asked Apr 07 '16 10:04

Evgeniy


People also ask

What character encoding is HTTP?

HTTP messages are encoded with ISO-8859-1 (which can be nominally considered as an enhanced ASCII version, containing umlauts, diacritic and other characters of West European languages). At the same time, the message body can use another encoding assigned in "Content-Type" header.

Which HTTP status code is usually returned when a resource was found and returned?

The origin server MUST create the resource before returning the 201 status code. If the action cannot be carried out immediately, the server SHOULD respond with 202 (Accepted) response instead.


1 Answers

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

like image 97
Julian Reschke Avatar answered Oct 05 '22 12:10

Julian Reschke