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