serve/net/http/codes.lua

changeset 138
561f0af6c9dc
equal deleted inserted replaced
137:091212cef52a 138:561f0af6c9dc
1
2 local response_codes = {
3 -- Source: http://www.iana.org/assignments/http-status-codes
4
5 [100] = "Continue"; -- RFC7231, Section 6.2.1
6 [101] = "Switching Protocols"; -- RFC7231, Section 6.2.2
7 [102] = "Processing";
8 [103] = "Early Hints";
9 -- [104-199] = "Unassigned";
10
11 [200] = "OK"; -- RFC7231, Section 6.3.1
12 [201] = "Created"; -- RFC7231, Section 6.3.2
13 [202] = "Accepted"; -- RFC7231, Section 6.3.3
14 [203] = "Non-Authoritative Information"; -- RFC7231, Section 6.3.4
15 [204] = "No Content"; -- RFC7231, Section 6.3.5
16 [205] = "Reset Content"; -- RFC7231, Section 6.3.6
17 [206] = "Partial Content"; -- RFC7233, Section 4.1
18 [207] = "Multi-Status";
19 [208] = "Already Reported";
20 -- [209-225] = "Unassigned";
21 [226] = "IM Used";
22 -- [227-299] = "Unassigned";
23
24 [300] = "Multiple Choices"; -- RFC7231, Section 6.4.1
25 [301] = "Moved Permanently"; -- RFC7231, Section 6.4.2
26 [302] = "Found"; -- RFC7231, Section 6.4.3
27 [303] = "See Other"; -- RFC7231, Section 6.4.4
28 [304] = "Not Modified"; -- RFC7232, Section 4.1
29 [305] = "Use Proxy"; -- RFC7231, Section 6.4.5
30 -- [306] = "(Unused)"; -- RFC7231, Section 6.4.6
31 [307] = "Temporary Redirect"; -- RFC7231, Section 6.4.7
32 [308] = "Permanent Redirect";
33 -- [309-399] = "Unassigned";
34
35 [400] = "Bad Request"; -- RFC7231, Section 6.5.1
36 [401] = "Unauthorized"; -- RFC7235, Section 3.1
37 [402] = "Payment Required"; -- RFC7231, Section 6.5.2
38 [403] = "Forbidden"; -- RFC7231, Section 6.5.3
39 [404] = "Not Found"; -- RFC7231, Section 6.5.4
40 [405] = "Method Not Allowed"; -- RFC7231, Section 6.5.5
41 [406] = "Not Acceptable"; -- RFC7231, Section 6.5.6
42 [407] = "Proxy Authentication Required"; -- RFC7235, Section 3.2
43 [408] = "Request Timeout"; -- RFC7231, Section 6.5.7
44 [409] = "Conflict"; -- RFC7231, Section 6.5.8
45 [410] = "Gone"; -- RFC7231, Section 6.5.9
46 [411] = "Length Required"; -- RFC7231, Section 6.5.10
47 [412] = "Precondition Failed"; -- RFC7232, Section 4.2
48 [413] = "Payload Too Large"; -- RFC7231, Section 6.5.11
49 [414] = "URI Too Long"; -- RFC7231, Section 6.5.12
50 [415] = "Unsupported Media Type"; -- RFC7231, Section 6.5.13
51 [416] = "Range Not Satisfiable"; -- RFC7233, Section 4.4
52 [417] = "Expectation Failed"; -- RFC7231, Section 6.5.14
53 [418] = "I'm a teapot"; -- RFC2324, Section 2.3.2
54 -- [419-420] = "Unassigned";
55 [421] = "Misdirected Request"; -- RFC7540, Section 9.1.2
56 [422] = "Unprocessable Entity";
57 [423] = "Locked";
58 [424] = "Failed Dependency";
59 [425] = "Too Early";
60 [426] = "Upgrade Required"; -- RFC7231, Section 6.5.15
61 -- [427] = "Unassigned";
62 [428] = "Precondition Required";
63 [429] = "Too Many Requests";
64 -- [430] = "Unassigned";
65 [431] = "Request Header Fields Too Large";
66 -- [432-450] = "Unassigned";
67 [451] = "Unavailable For Legal Reasons";
68 -- [452-499] = "Unassigned";
69
70 [500] = "Internal Server Error"; -- RFC7231, Section 6.6.1
71 [501] = "Not Implemented"; -- RFC7231, Section 6.6.2
72 [502] = "Bad Gateway"; -- RFC7231, Section 6.6.3
73 [503] = "Service Unavailable"; -- RFC7231, Section 6.6.4
74 [504] = "Gateway Timeout"; -- RFC7231, Section 6.6.5
75 [505] = "HTTP Version Not Supported"; -- RFC7231, Section 6.6.6
76 [506] = "Variant Also Negotiates";
77 [507] = "Insufficient Storage";
78 [508] = "Loop Detected";
79 -- [509] = "Unassigned";
80 [510] = "Not Extended";
81 [511] = "Network Authentication Required";
82 -- [512-599] = "Unassigned";
83 };
84
85 for k,v in pairs(response_codes) do response_codes[k] = k.." "..v; end
86 return setmetatable(response_codes, { __index = function(_, k) return k.." Unassigned"; end })

mercurial