内容长度与实际内容长度不匹配的适当 HTTP 状态代码是什么
我知道缺少内容长度标头是 411,但不确定当内容长度中给出的值与实际内容长度不匹配时我应该如何响应
I know that missing the content-length header is a 411, but not sure how I should respond when the value given in the content-length does not match the actual content length
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该标准似乎没有提及要响应的实际代码,只是两个长度必须匹配并且 HTTP/1.1 代理必须通知用户。
我只会使用
400 Bad Request
代码,因为毕竟这就是问题所在(违反标准的请求),并且其他 400 系列代码似乎都没有足够接近的匹配。x00
代码还定义状态的类,因此可用于通用代码。请记住,代码是可扩展的,您始终可以定义自己的代码,并且无法识别它的代理无论如何都需要将其视为
x00
变体(RFC2616 的第 6.1.1 节):The standard seems silent on the actual code to respond with, only that the two lengths MUST match and that HTTP/1.1 agents MUST notify the user.
I would just use the
400 Bad Request
code since that is, after all, what the problem is (a request violating the standard) and none of the other 400-series codes seems a close enough match. Thex00
codes also define the class of a status so can be used for a generic code.Keep in mind that the codes are extendable, you can always define your own, and agents that don't recognise it are required to treat it as an
x00
variant anyway (section 6.1.1 of RFC2616):