gpt4 book ai didi

违反发布要求的 HTTP 403 或 406?

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

简单问题:

我有一个 POST 端点,它需要一些文本输入。输入的文本不得超过 x 个字符。如果是,我会回复一条错误消息。

但是哪个 HTTP 状态码才是正确的呢?

0.4.4 403 Forbidden

The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. [..]

10.4.7 406 Not Acceptable

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

10.4.18 417 Expectation Failed

The expectation given in an Expect request-header field [..] could not be met by this server [..]

Source: w3.org

最佳答案

我猜这是存在的问题。很快,正确的 HTTP 代码是 400 + 可选描述

您可以在此处查看更详细的答案:REST HTTP status codes for failed validation or invalid duplicate

关于违反发布要求的 HTTP 403 或 406?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34327947/

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