Skip to content

Commit

Permalink
Merge pull request #644 from milkey-mouse/master
Browse files Browse the repository at this point in the history
Add more HTTP status codes
  • Loading branch information
asvetlov committed Nov 27, 2015
2 parents 4b41e69 + 93cbf20 commit 7f29b7e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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

0 comments on commit 7f29b7e

Please sign in to comment.