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

Add more HTTP status codes #644

Merged
merged 4 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
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
40 changes: 40 additions & 0 deletions aiohttp/web_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,21 @@
'HTTPUnsupportedMediaType',
'HTTPRequestRangeNotSatisfiable',
'HTTPExpectationFailed',
'HTTPMisdirectedRequest',
'HTTPUpgradeRequired',
'HTTPPreconditionRequired',
'HTTPTooManyRequests',
'HTTPRequestHeaderFieldsTooLarge',
'HTTPServerError',
'HTTPInternalServerError',
'HTTPNotImplemented',
'HTTPBadGateway',
'HTTPServiceUnavailable',
'HTTPGatewayTimeout',
'HTTPVersionNotSupported',
'HTTPVariantAlsoNegotiates',
'HTTPNotExtended',
'HTTPNetworkAuthenticationRequired',
)


Expand Down Expand Up @@ -253,6 +261,26 @@ class HTTPExpectationFailed(HTTPClientError):
status_code = 417


class HTTPMisdirectedRequest(HTTPClientError):
status_code = 421


class HTTPUpgradeRequired(HTTPClientError):
status_code = 426


class HTTPPreconditionRequired(HTTPClientError):
status_code = 428


class HTTPTooManyRequests(HTTPClientError):
status_code = 429


class HTTPRequestHeaderFieldsTooLarge(HTTPClientError):
status_code = 431


############################################################
# 5xx Server Error
############################################################
Expand Down Expand Up @@ -291,3 +319,15 @@ class HTTPGatewayTimeout(HTTPServerError):

class HTTPVersionNotSupported(HTTPServerError):
status_code = 505


class HTTPVariantAlsoNegotiates(HTTPServerError):
status_code = 506


class HTTPNotExtended(HTTPServerError):
status_code = 510


class HTTPNetworkAuthenticationRequired(HTTPServerError):
status_code = 511
8 changes: 8 additions & 0 deletions docs/web.rst
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,21 @@ HTTP Exception hierarchy chart::
* 415 - HTTPUnsupportedMediaType
* 416 - HTTPRequestRangeNotSatisfiable
* 417 - HTTPExpectationFailed
* 421 - HTTPMisdirectedRequest
* 426 - HTTPUpgradeRequired
* 428 - HTTPPreconditionRequired
* 429 - HTTPTooManyRequests
* 431 - HTTPRequestHeaderFieldsTooLarge
HTTPServerError
* 500 - HTTPInternalServerError
* 501 - HTTPNotImplemented
* 502 - HTTPBadGateway
* 503 - HTTPServiceUnavailable
* 504 - HTTPGatewayTimeout
* 505 - HTTPVersionNotSupported
* 506 - HTTPVariantAlsoNegotiates
* 510 - HTTPNotExtended
* 511 - HTTPNetworkAuthenticationRequired

All HTTP exceptions have the same constructor::

Expand Down