| 1 |
from . import utils |
| 2 |
|
| 3 |
content_types = utils.invert_dict({ |
| 4 |
"application/json": ["json"], |
| 5 |
"application/wasm": ["wasm"], |
| 6 |
"application/xhtml+xml": ["xht", "xhtm", "xhtml"], |
| 7 |
"application/xml": ["xml"], |
| 8 |
"application/x-xpinstall": ["xpi"], |
| 9 |
"audio/mp4": ["m4a"], |
| 10 |
"audio/mpeg": ["mp3"], |
| 11 |
"audio/ogg": ["oga"], |
| 12 |
"audio/webm": ["weba"], |
| 13 |
"audio/x-wav": ["wav"], |
| 14 |
"image/avif": ["avif"], |
| 15 |
"image/bmp": ["bmp"], |
| 16 |
"image/gif": ["gif"], |
| 17 |
"image/jpeg": ["jpg", "jpeg"], |
| 18 |
"image/png": ["png"], |
| 19 |
"image/svg+xml": ["svg"], |
| 20 |
"text/cache-manifest": ["manifest"], |
| 21 |
"text/css": ["css"], |
| 22 |
"text/event-stream": ["event_stream"], |
| 23 |
"text/html": ["htm", "html"], |
| 24 |
"text/javascript": ["js", "mjs"], |
| 25 |
"text/plain": ["txt", "md"], |
| 26 |
"text/vtt": ["vtt"], |
| 27 |
"video/mp4": ["mp4", "m4v"], |
| 28 |
"video/webm": ["webm"], |
| 29 |
}) |
| 30 |
|
| 31 |
response_codes = { |
| 32 |
100: ('Continue', 'Request received, please continue'), |
| 33 |
101: ('Switching Protocols', |
| 34 |
'Switching to new protocol; obey Upgrade header'), |
| 35 |
|
| 36 |
200: ('OK', 'Request fulfilled, document follows'), |
| 37 |
201: ('Created', 'Document created, URL follows'), |
| 38 |
202: ('Accepted', |
| 39 |
'Request accepted, processing continues off-line'), |
| 40 |
203: ('Non-Authoritative Information', 'Request fulfilled from cache'), |
| 41 |
204: ('No Content', 'Request fulfilled, nothing follows'), |
| 42 |
205: ('Reset Content', 'Clear input form for further input.'), |
| 43 |
206: ('Partial Content', 'Partial content follows.'), |
| 44 |
|
| 45 |
300: ('Multiple Choices', |
| 46 |
'Object has several resources -- see URI list'), |
| 47 |
301: ('Moved Permanently', 'Object moved permanently -- see URI list'), |
| 48 |
302: ('Found', 'Object moved temporarily -- see URI list'), |
| 49 |
303: ('See Other', 'Object moved -- see Method and URL list'), |
| 50 |
304: ('Not Modified', |
| 51 |
'Document has not changed since given time'), |
| 52 |
305: ('Use Proxy', |
| 53 |
'You must use proxy specified in Location to access this ' |
| 54 |
'resource.'), |
| 55 |
307: ('Temporary Redirect', |
| 56 |
'Object moved temporarily -- see URI list'), |
| 57 |
|
| 58 |
400: ('Bad Request', |
| 59 |
'Bad request syntax or unsupported method'), |
| 60 |
401: ('Unauthorized', |
| 61 |
'No permission -- see authorization schemes'), |
| 62 |
402: ('Payment Required', |
| 63 |
'No payment -- see charging schemes'), |
| 64 |
403: ('Forbidden', |
| 65 |
'Request forbidden -- authorization will not help'), |
| 66 |
404: ('Not Found', 'Nothing matches the given URI'), |
| 67 |
405: ('Method Not Allowed', |
| 68 |
'Specified method is invalid for this resource.'), |
| 69 |
406: ('Not Acceptable', 'URI not available in preferred format.'), |
| 70 |
407: ('Proxy Authentication Required', 'You must authenticate with ' |
| 71 |
'this proxy before proceeding.'), |
| 72 |
408: ('Request Timeout', 'Request timed out; try again later.'), |
| 73 |
409: ('Conflict', 'Request conflict.'), |
| 74 |
410: ('Gone', |
| 75 |
'URI no longer exists and has been permanently removed.'), |
| 76 |
411: ('Length Required', 'Client must specify Content-Length.'), |
| 77 |
412: ('Precondition Failed', 'Precondition in headers is false.'), |
| 78 |
413: ('Request Entity Too Large', 'Entity is too large.'), |
| 79 |
414: ('Request-URI Too Long', 'URI is too long.'), |
| 80 |
415: ('Unsupported Media Type', 'Entity body in unsupported format.'), |
| 81 |
416: ('Requested Range Not Satisfiable', |
| 82 |
'Cannot satisfy request range.'), |
| 83 |
417: ('Expectation Failed', |
| 84 |
'Expect condition could not be satisfied.'), |
| 85 |
|
| 86 |
500: ('Internal Server Error', 'Server got itself in trouble'), |
| 87 |
501: ('Not Implemented', |
| 88 |
'Server does not support this operation'), |
| 89 |
502: ('Bad Gateway', 'Invalid responses from another server/proxy.'), |
| 90 |
503: ('Service Unavailable', |
| 91 |
'The server cannot process the request due to a high load'), |
| 92 |
504: ('Gateway Timeout', |
| 93 |
'The gateway server did not receive a timely response'), |
| 94 |
505: ('HTTP Version Not Supported', 'Cannot fulfill request.'), |
| 95 |
} |
| 96 |
|
| 97 |
h2_headers = ['method', 'scheme', 'host', 'path', 'authority', 'status'] |