指示客户端错误的 HTTP 响应代码
HTTP response code to indicate a bug in the client
我正在开发客户端和服务器。在开发过程中,我会让服务器检测客户端何时出现错误(发送无效数据、省略强制参数等)。
是否有标准的 HTTP 响应代码来表明这一点?还是几个,取决于错误的性质?
或者我应该只使用我自己的响应代码?
例如2001 I'm afraid I can't do that, Dave
?
或 666 Mwuuuuuuhahhahahahahahahaha
HTTP 400“错误请求”
https://www.rfc-editor.org/rfc/rfc7231#section-6.5.1
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
我正在开发客户端和服务器。在开发过程中,我会让服务器检测客户端何时出现错误(发送无效数据、省略强制参数等)。
是否有标准的 HTTP 响应代码来表明这一点?还是几个,取决于错误的性质?
或者我应该只使用我自己的响应代码?
例如2001 I'm afraid I can't do that, Dave
?
或 666 Mwuuuuuuhahhahahahahahahaha
HTTP 400“错误请求”
https://www.rfc-editor.org/rfc/rfc7231#section-6.5.1
The 400 (Bad Request) status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).