status_codes.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # -*- coding: utf-8 -*-
  2. from .structures import LookupDict
  3. _codes = {
  4. # Informational.
  5. 100: ('continue',),
  6. 101: ('switching_protocols',),
  7. 102: ('processing',),
  8. 103: ('checkpoint',),
  9. 122: ('uri_too_long', 'request_uri_too_long'),
  10. 200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),
  11. 201: ('created',),
  12. 202: ('accepted',),
  13. 203: ('non_authoritative_info', 'non_authoritative_information'),
  14. 204: ('no_content',),
  15. 205: ('reset_content', 'reset'),
  16. 206: ('partial_content', 'partial'),
  17. 207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'),
  18. 208: ('already_reported',),
  19. 226: ('im_used',),
  20. # Redirection.
  21. 300: ('multiple_choices',),
  22. 301: ('moved_permanently', 'moved', '\\o-'),
  23. 302: ('found',),
  24. 303: ('see_other', 'other'),
  25. 304: ('not_modified',),
  26. 305: ('use_proxy',),
  27. 306: ('switch_proxy',),
  28. 307: ('temporary_redirect', 'temporary_moved', 'temporary'),
  29. 308: ('permanent_redirect',
  30. 'resume_incomplete', 'resume',), # These 2 to be removed in 3.0
  31. # Client Error.
  32. 400: ('bad_request', 'bad'),
  33. 401: ('unauthorized',),
  34. 402: ('payment_required', 'payment'),
  35. 403: ('forbidden',),
  36. 404: ('not_found', '-o-'),
  37. 405: ('method_not_allowed', 'not_allowed'),
  38. 406: ('not_acceptable',),
  39. 407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'),
  40. 408: ('request_timeout', 'timeout'),
  41. 409: ('conflict',),
  42. 410: ('gone',),
  43. 411: ('length_required',),
  44. 412: ('precondition_failed', 'precondition'),
  45. 413: ('request_entity_too_large',),
  46. 414: ('request_uri_too_large',),
  47. 415: ('unsupported_media_type', 'unsupported_media', 'media_type'),
  48. 416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'),
  49. 417: ('expectation_failed',),
  50. 418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'),
  51. 422: ('unprocessable_entity', 'unprocessable'),
  52. 423: ('locked',),
  53. 424: ('failed_dependency', 'dependency'),
  54. 425: ('unordered_collection', 'unordered'),
  55. 426: ('upgrade_required', 'upgrade'),
  56. 428: ('precondition_required', 'precondition'),
  57. 429: ('too_many_requests', 'too_many'),
  58. 431: ('header_fields_too_large', 'fields_too_large'),
  59. 444: ('no_response', 'none'),
  60. 449: ('retry_with', 'retry'),
  61. 450: ('blocked_by_windows_parental_controls', 'parental_controls'),
  62. 451: ('unavailable_for_legal_reasons', 'legal_reasons'),
  63. 499: ('client_closed_request',),
  64. # Server Error.
  65. 500: ('internal_server_error', 'server_error', '/o\\', '✗'),
  66. 501: ('not_implemented',),
  67. 502: ('bad_gateway',),
  68. 503: ('service_unavailable', 'unavailable'),
  69. 504: ('gateway_timeout',),
  70. 505: ('http_version_not_supported', 'http_version'),
  71. 506: ('variant_also_negotiates',),
  72. 507: ('insufficient_storage',),
  73. 509: ('bandwidth_limit_exceeded', 'bandwidth'),
  74. 510: ('not_extended',),
  75. }
  76. codes = LookupDict(name='status_codes')
  77. for (code, titles) in list(_codes.items()):
  78. for title in titles:
  79. setattr(codes, title, code)
  80. if not title.startswith('\\'):
  81. setattr(codes, title.upper(), code)