Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional HTTP Status Codes #1372

Merged
merged 2 commits into from
Nov 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions pyramid/httpexceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
* 422 - HTTPUnprocessableEntity
* 423 - HTTPLocked
* 424 - HTTPFailedDependency
* 428 - HTTPPreconditionRequired
* 429 - HTTPTooManyRequests
* 431 - HTTPRequestHeaderFieldsTooLarge
HTTPServerError
* 500 - HTTPInternalServerError
* 501 - HTTPNotImplemented
Expand Down Expand Up @@ -907,6 +910,62 @@ class HTTPFailedDependency(HTTPClientError):
'The method could not be performed because the requested '
'action dependended on another action and that action failed')

class HTTPPreconditionRequired(HTTPClientError):
"""
subclass of :class:`~HTTPClientError`

This indicates that the origin server requires the
request to be conditional.

Its typical use is to avoid the "lost update" problem, where a client
GETs a resource's state, modifies it, and PUTs it back to the server,
when meanwhile a third party has modified the state on the server,
leading to a conflict. By requiring requests to be conditional, the
server can assure that clients are working with the correct copies.

RFC 6585.3

code: 428, title: Precondition Required
"""
code = 428
title = 'Precondition Required'
explanation = (
'The origin server requires the request to be conditional.')

class HTTPTooManyRequests(HTTPClientError):
"""
subclass of :class:`~HTTPClientError`

This indicates that the user has sent too many
requests in a given amount of time ("rate limiting").

RFC 6585.4

code: 429, title: Too Many Requests
"""
code = 429
title = 'Too Many Requests'
explanation = (
'The action could not be performed because there were too '
'many requests by the client.')

class HTTPRequestHeaderFieldsTooLarge(HTTPClientError):
"""
subclass of :class:`~HTTPClientError`

This indicates that the server is unwilling to process
the request because its header fields are too large. The request MAY
be resubmitted after reducing the size of the request header fields.

RFC 6585.5

code: 431, title: Request Header Fields Too Large
"""
code = 431
title = 'Request Header Fields Too Large'
explanation = (
'The requests header fields were too large.')

############################################################
## 5xx Server Error
############################################################
Expand Down