gpt4 book ai didi

http - 406 Not Acceptable 负载的格式?

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

在 406 Not Acceptable 响应中:

The server SHOULD generate a payload containing a list of available representation characteristics and corresponding resource identifiers from 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 in RFC7231 Section 6.4.1.

可用表示特征和相应资源标识符列表”是否有首选格式?

我可以发送如下回复:

{ Acceptable: ["application/json", "application/pdf"] }

但是我假设 406 有效载荷的默认内容类型(在本例中为 JSON)。

或者我应该发送一个非常简单的、几乎无格式的有效负载,例如:

application/json,application/pdf

最佳答案

Is there a preferred format for that "list of available representation characteristics and corresponding resource identifiers"?

此类负载没有标准。

您可以选择用户代理可以轻松解析的任何格式。在实践中,JSON 或文本都应该没问题:

{ "acceptable" : [ "application/json", "application/pdf" ] }
application/json,application/pdf

请参阅 6.4.1 部分的以下引述的 RFC 7231 ,在 406 中引用状态码定义:

[...] A specific format for automatic selection is not defined bythis specification because HTTP tries to remain orthogonal to thedefinition of its payloads. In practice, the representation isprovided in some easily parsed format believed to be acceptable tothe user agent, as determined by shared design or contentnegotiation, or in some commonly accepted hypertext format. [...]

Mozilla 的 MDN Web 文档建议 following :

[...] In reality, this error is very rarely used: instead of responding using this error code, which would be cryptic for the end user and difficult to fix, servers ignore the relevant header and serve an actual page to the user. It is assumed that even if the user won't be completely happy, they will prefer this to an error code. [...]

关于http - 406 Not Acceptable 负载的格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50102277/

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