[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Change reason phrase
From: |
Evgeny Grin |
Subject: |
Re: [libmicrohttpd] Change reason phrase |
Date: |
Tue, 6 Dec 2022 09:32:13 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 |
From the new RFC 9112.
https://www.rfc-editor.org/rfc/rfc9112.html#section-4
------------------------------------------------------
A client SHOULD ignore the reason-phrase content because it is not a
reliable channel for information (it might be translated for a given
locale, overwritten by intermediaries, or discarded when the message is
forwarded via other versions of HTTP).
------------------------------------------------------
So unless you are communicating only within a closed network, you cannot
be sure that "reason-phrase" will be delivered.
HTTP is quite flexible, so you could deliver the same message via
special header or within the body (context) or your reply.
The simplest way is use special header, like
Unauthorized-Reason: Account frozen
This is very simple, supported by HTTP, reliable and could be easily
implemented with current MHD API.
--
Evgeny
On 06.12.2022 8:52, Christian Grothoff wrote:
Well, the RFC says that the client SHOULD ignore it. Yes, the server MAY
change it, but to rely on it doesn't create a robust protocol: For
example, by my reading, HTTP (reverse) proxies between client and server
MAY change the message...
So yes, having the 'wrong' message technically doesn't break the
standard, but using the message to convey significant information does.
On 12/6/22 05:24, Tiaan via libmicrohttpd wrote:
Thank you, importantly you've answered my question that it is not
possible.
May I complete the record then and respectfully disagree with your
assessment of the merit. I quote from RFC7231:
6.1 <https://www.rfc-editor.org/rfc/rfc7231#section-6.1>. Overview of
Status Codes
The status codes listed below are defined in this specification,
Section 4 of [RFC7232]
<https://www.rfc-editor.org/rfc/rfc7232#section-4>, Section 4 of
[RFC7233] <https://www.rfc-editor.org/rfc/rfc7233#section-4>, and
Section 3 of
[RFC7235] <https://www.rfc-editor.org/rfc/rfc7235#section-3>. The
reason phrases listed here are only recommendations
-- they can be replaced by local equivalents without affecting the
protocol.
and from 7230:
The reason-phrase element exists for the sole purpose of providing a
textual description associated with the numeric status code, mostly
out of deference to earlier Internet application protocols that were
more frequently used with interactive text clients. A client SHOULD
ignore the reason-phrase content.
reason-phrase = *( HTAB / SP / VCHAR / obs-text )
Regards
Only by changing the source code and recompiling MHD. But you should not
do this, this is a very bad idea. You should stick to the standard
messages of the HTTP protocol. If you need to convey additional
information, do it in the body or in a header; try to use HTTP status
codes narrowly to what the HTTP standard says they are for.
On 12/5/22 10:26, Tiaan via libmicrohttpd wrote:
Hi, is it possible to change the reason phrase of responses e.g.
instead
of
HTTP/1.1 401 Unauthorized rather HTTP/1.1 401 Account frozen?
OpenPGP_0x460A317C3326D2AE.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature