验证码的 HTTP 状态代码

标签 http captcha http-status-codes http-status-code-503 http-status-code-409

有时(当资源请求过于频繁时)我会使用验证码拦截 (HTML) 资源的呈现。拦截不会产生任何重定向。它都发生在同一个 URI 上。

我现在想知道哪种 HTTP 状态代码最适合这些要求:

  • 它应该符合语义。

  • Google 应该明白,这种拦截是一种临时情况,不应影响其索引中的现有资源。

  • Web 浏览器将显示带有验证码的响应正文。

这些是我目前确定的候选人:

409 Conflict

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough information for the user to recognize the source of the conflict.

这听起来很完美。冲突状态来自那些过于频繁地请求资源的客户端。响应还包括足够的信息来识别冲突的来源并解决它。

503 Service Unavailable

The server is currently unable to handle the request due to a temporary overloading […] of the server. The implication is that this is a temporary condition […]. If known, the length of the delay MAY be indicated in a Retry-After header.

这听起来还算合适。我什至可能知道延迟的长度并提供这样的标题。但是我在这里缺少用户可以解决问题的要点。此外,范围太广(服务器过载与资源过载)。

最佳答案

您可能需要考虑在 https://www.rfc-editor.org/rfc/rfc6585#section-4 中定义的状态码 429 .

关于验证码的 HTTP 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26547466/

相关文章:

java - 来自服务器的字符串无法转换为 JSONObject?

c++ - Qt- QNetworkReply 不显示 Content-Length header

Java如何在通过Servlet类生成的jsp中刷新验证码

recaptcha - 如何在单个页面上显示多个recaptchas?

jQuery ajax - 在调用 statusCode() 回调时避免 error() 回调

http-headers - 如果缺少必需的 header ,返回的最合适的 HTTP 状态代码是什么?

node.js - 当我不回答请求时,如何防止 express 发送 "502 Bad Gateway"?

c# - 如何获取 WinPhone WebClient 返回的 HTTP 状态码?

ruby-on-rails - Rails 简单验证码不通过 HTTPS

android - http post setEntity 使用改造