Path: blob/master/venv/Lib/site-packages/requests/status_codes.py
811 views
# -*- coding: utf-8 -*-12r"""3The ``codes`` object defines a mapping from common names for HTTP statuses4to their numerical codes, accessible either as attributes or as dictionary5items.67Example::89>>> import requests10>>> requests.codes['temporary_redirect']1130712>>> requests.codes.teapot1341814>>> requests.codes['\o/']152001617Some codes have multiple names, and both upper- and lower-case versions of18the names are allowed. For example, ``codes.ok``, ``codes.OK``, and19``codes.okay`` all correspond to the HTTP status code 200.20"""2122from .structures import LookupDict2324_codes = {2526# Informational.27100: ('continue',),28101: ('switching_protocols',),29102: ('processing',),30103: ('checkpoint',),31122: ('uri_too_long', 'request_uri_too_long'),32200: ('ok', 'okay', 'all_ok', 'all_okay', 'all_good', '\\o/', '✓'),33201: ('created',),34202: ('accepted',),35203: ('non_authoritative_info', 'non_authoritative_information'),36204: ('no_content',),37205: ('reset_content', 'reset'),38206: ('partial_content', 'partial'),39207: ('multi_status', 'multiple_status', 'multi_stati', 'multiple_stati'),40208: ('already_reported',),41226: ('im_used',),4243# Redirection.44300: ('multiple_choices',),45301: ('moved_permanently', 'moved', '\\o-'),46302: ('found',),47303: ('see_other', 'other'),48304: ('not_modified',),49305: ('use_proxy',),50306: ('switch_proxy',),51307: ('temporary_redirect', 'temporary_moved', 'temporary'),52308: ('permanent_redirect',53'resume_incomplete', 'resume',), # These 2 to be removed in 3.05455# Client Error.56400: ('bad_request', 'bad'),57401: ('unauthorized',),58402: ('payment_required', 'payment'),59403: ('forbidden',),60404: ('not_found', '-o-'),61405: ('method_not_allowed', 'not_allowed'),62406: ('not_acceptable',),63407: ('proxy_authentication_required', 'proxy_auth', 'proxy_authentication'),64408: ('request_timeout', 'timeout'),65409: ('conflict',),66410: ('gone',),67411: ('length_required',),68412: ('precondition_failed', 'precondition'),69413: ('request_entity_too_large',),70414: ('request_uri_too_large',),71415: ('unsupported_media_type', 'unsupported_media', 'media_type'),72416: ('requested_range_not_satisfiable', 'requested_range', 'range_not_satisfiable'),73417: ('expectation_failed',),74418: ('im_a_teapot', 'teapot', 'i_am_a_teapot'),75421: ('misdirected_request',),76422: ('unprocessable_entity', 'unprocessable'),77423: ('locked',),78424: ('failed_dependency', 'dependency'),79425: ('unordered_collection', 'unordered'),80426: ('upgrade_required', 'upgrade'),81428: ('precondition_required', 'precondition'),82429: ('too_many_requests', 'too_many'),83431: ('header_fields_too_large', 'fields_too_large'),84444: ('no_response', 'none'),85449: ('retry_with', 'retry'),86450: ('blocked_by_windows_parental_controls', 'parental_controls'),87451: ('unavailable_for_legal_reasons', 'legal_reasons'),88499: ('client_closed_request',),8990# Server Error.91500: ('internal_server_error', 'server_error', '/o\\', '✗'),92501: ('not_implemented',),93502: ('bad_gateway',),94503: ('service_unavailable', 'unavailable'),95504: ('gateway_timeout',),96505: ('http_version_not_supported', 'http_version'),97506: ('variant_also_negotiates',),98507: ('insufficient_storage',),99509: ('bandwidth_limit_exceeded', 'bandwidth'),100510: ('not_extended',),101511: ('network_authentication_required', 'network_auth', 'network_authentication'),102}103104codes = LookupDict(name='status_codes')105106def _init():107for code, titles in _codes.items():108for title in titles:109setattr(codes, title, code)110if not title.startswith(('\\', '/')):111setattr(codes, title.upper(), code)112113def doc(code):114names = ', '.join('``%s``' % n for n in _codes[code])115return '* %d: %s' % (code, names)116117global __doc__118__doc__ = (__doc__ + '\n' +119'\n'.join(doc(code) for code in sorted(_codes))120if __doc__ is not None else None)121122_init()123124125