当服务器怀疑发布的表单数据是垃圾邮件时使用的 http 状态代码

标签 http

撇开您是否应该向向您发送垃圾邮件的人返回“有用的”http 状态代码的问题,在这种情况下适当的 http 响应代码应该是什么。假设您正在扫描表单以查找列入黑名单的单词,并且提交有一些。

最佳答案

403 Forbidden 似乎是最合适的代码。来自 RFC 2616 的描述说:

The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.

更好的选择可能是新的 422 Unprocessable Entity 代码,定义在 RFC 4918 中.

The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.

blog post推荐它用于像您这样的情况,其中发布的内容存在语义问题,而不是句法问题。

关于当服务器怀疑发布的表单数据是垃圾邮件时使用的 http 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23645147/

相关文章:

php - cURL 请求 PHP 的空白响应

java - @ResponseBody 注解在响应中重置 header

http - 可以 gzip 压缩对 http 请求错误的响应吗?

html - 我如何从网页或 URL 知道地理来源?

java - 从链接中提取数据会更改检索时的语言

JAVA HTTP 客户端和 Serlvlet

javascript - 浏览器中来自 Javascript 的 REST API 身份验证

http - Tomcat 中的 WebDAV 服务器端实现

android - 适用于 Android 的 Flurry Analytics : Data not being sent to Flurry dashboard?

forms - 一个 <input> 中的 HTTP multipart/form-data 多个文件