Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Status Code for Captcha

Sometimes (when the resource is requested too often) I'm intercepting the presentation of a (HTML) resource with a captcha. The interception doesn't produce any redirection. It happens all at the same URI.

I'm wondering now which HTTP status code would fit most for these requirements:

  • it should fit semantically.

  • Google should understand that this interception is a temporary condition which should not affect the existing resource in its index.

  • A web browser will display the response body with the captcha.

These are my candidates which I identified so far:

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.

This sounds perfect. The conflict state comes from those clients requesting the resource too often. The response also includes enough information to identify the source of conflict plus resolve it.

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.

This sounds moderately appropriate. I might even know the length of delay and provide such header. But I'm missing here the point that the user can resolve the problem. Furthermore the scope is too broad (overloaded server vs. overloaded resource).

like image 962
Markus Malkusch Avatar asked Oct 24 '14 12:10

Markus Malkusch


People also ask

What is a 309 status code?

Status codes 309 through 399 are currently unassigned.

What is a 299 status code?

HTTP response codes 200 – 299 are bearers of good news: the request has been accepted, a new request has been created, or a certain problem was solved.

What is HTTP status code1?

We tend to get -1 status codes when there are network issues or connection problems, so we display the user a network problems page in those cases.

When should I use HTTP 203?

The HTTP 203 Non-Authoritative Information response status indicates that the request was successful but the enclosed payload has been modified by a transforming proxy from that of the origin server's 200 ( OK ) response .


2 Answers

For me 422 is somewhat accurate for this case:

response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.

like image 30
Levi Dulstein Avatar answered Sep 25 '22 17:09

Levi Dulstein


You may want to consider status code 429, defined in https://www.rfc-editor.org/rfc/rfc6585#section-4.

like image 56
Julian Reschke Avatar answered Sep 24 '22 17:09

Julian Reschke