gpt4 book ai didi

http - "accept type not supported"的响应码

转载 作者:可可西里 更新时间:2023-11-01 16:56:02 25 4
gpt4 key购买 nike

对于带有我不支持的 Accept header 的请求,正确的响应代码是什么?

例如,如果带有 Accept header application/json 的请求进入,但我支持的唯一响应类型是 text/plaintext/html,我应该返回什么响应码?

最佳答案

根据 RFC 7231,这将是 HTTP 响应 406:

6.5.6. 406 Not Acceptable

The 406 (Not Acceptable) status code indicates that the target
resource does not have a current representation that would be
acceptable to the user agent, according to the proactive negotiation
header fields received in the request (Section 5.3), and the server
is unwilling to supply a default representation.

The server SHOULD generate a payload containing a list of availablerepresentation characteristics and corresponding resource identifiersfrom which the user or user agent can choose the one most
appropriate. A user agent MAY automatically select the most
appropriate choice from that list. However, this specification does
not define any standard for such automatic selection, as described inSection 6.4.1.

来源:https://www.rfc-editor.org/rfc/rfc7231#section-6.5.6

关于http - "accept type not supported"的响应码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28478836/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com