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

Add HTTPExceptions for 428, 429, and 431 #200

Merged
merged 2 commits into from Jan 7, 2013
Jump to file or symbol
Failed to load files and symbols.
+49 −0
Diff settings

Always

Just for now

Next

Adding HTTPException subclasses for HTTP statuses 428, 429, and 431,

which were recently added in RFC 6585.
  • Loading branch information...
jessaustin committed Jul 10, 2012
commit ff5fa21e5192da342ca84232baab864e349473e6
View
@@ -44,6 +44,12 @@ The following error classes exist in Werkzeug:
.. autoexception:: ImATeapot
.. autoexception:: PreconditionRequired
.. autoexception:: TooManyRequests
.. autoexception:: RequestHeaderFieldsTooLarge
.. autoexception:: InternalServerError
.. autoexception:: NotImplemented
View
@@ -436,6 +436,49 @@ class UnprocessableEntity(HTTPException):
'<p>The request was well-formed but was unable to be followed due to semantic errors.'
)
class PreconditionRequired(HTTPException):
"""*428* `Precondition Required`
The server requires this request to be conditional, typically to prevent
the lost update problem, which is a race condition between two or more
clients attempting to update a resource through PUT or DELETE. By requiring
each client to include a conditional header ("If-Match" or "If-Unmodified-
Since") with the proper value retained from a recent GET request, the
server ensures that each client has at least seen the previous revision of
the resource.
"""
code = 428
description = (
'<p>This request is required to be conditional; try using "If-Match" '
'or "If-Unmodified-Since".'
)
class TooManyRequests(HTTPException):
"""*429* `Too Many Requests`
The server is limiting the rate at which this user receives responses, and
this request exceeds that rate. (The server may use any convenient method
to identify users and their request rates). The server may include a
"Retry-After" header to indicate how long the user should wait before
retrying.
"""
code = 429
description = (
'<p>This user has exceeded an allotted request count. Try again later.'
)
class RequestHeaderFieldsTooLarge(HTTPException):
"""*431* `RequestHeaderFieldsTooLarge`
The server refuses to process the request because the header fields are too
large. One or more individual fields may be too large, or the set of all
headers is too large.
"""
code = 431
description = (
'<p>One or more header fields exceeds the maximum size.'
)
class InternalServerError(HTTPException):
"""*500* `Internal Server Error`
ProTip! Use n and p to navigate between commits in a pull request.