Annotate

net/http/codes.lua @ 11749:83d6d6a70edf

net.http: fail open if surrounding code does not configure TLS Previously, if surrounding code was not configuring the TLS context used default in net.http, it would not validate certificates at all. This is not a security issue with prosody, because prosody updates the context with `verify = "peer"` as well as paths to CA certificates in util.startup.init_http_client. Nevertheless... Let's not leave this pitfall out there in the open.
author Jonas Schäfer <jonas@wielicki.name>
date Sun, 29 Aug 2021 15:04:47 +0200
parent 10370:78bda7932f17
child 12548:5133d6e48686
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local response_codes = {
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 -- Source: http://www.iana.org/assignments/http-status-codes
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
5 [100] = "Continue"; -- RFC7231, Section 6.2.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
6 [101] = "Switching Protocols"; -- RFC7231, Section 6.2.2
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7 [102] = "Processing";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
8 [103] = "Early Hints";
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
9 -- [104-199] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
11 [200] = "OK"; -- RFC7231, Section 6.3.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
12 [201] = "Created"; -- RFC7231, Section 6.3.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
13 [202] = "Accepted"; -- RFC7231, Section 6.3.3
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
14 [203] = "Non-Authoritative Information"; -- RFC7231, Section 6.3.4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
15 [204] = "No Content"; -- RFC7231, Section 6.3.5
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
16 [205] = "Reset Content"; -- RFC7231, Section 6.3.6
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
17 [206] = "Partial Content"; -- RFC7233, Section 4.1
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 [207] = "Multi-Status";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 [208] = "Already Reported";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
20 -- [209-225] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21 [226] = "IM Used";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
22 -- [227-299] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
24 [300] = "Multiple Choices"; -- RFC7231, Section 6.4.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
25 [301] = "Moved Permanently"; -- RFC7231, Section 6.4.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
26 [302] = "Found"; -- RFC7231, Section 6.4.3
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
27 [303] = "See Other"; -- RFC7231, Section 6.4.4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
28 [304] = "Not Modified"; -- RFC7232, Section 4.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
29 [305] = "Use Proxy"; -- RFC7231, Section 6.4.5
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
30 -- [306] = "(Unused)"; -- RFC7231, Section 6.4.6
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
31 [307] = "Temporary Redirect"; -- RFC7231, Section 6.4.7
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
32 [308] = "Permanent Redirect";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
33 -- [309-399] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
35 [400] = "Bad Request"; -- RFC7231, Section 6.5.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
36 [401] = "Unauthorized"; -- RFC7235, Section 3.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
37 [402] = "Payment Required"; -- RFC7231, Section 6.5.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
38 [403] = "Forbidden"; -- RFC7231, Section 6.5.3
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
39 [404] = "Not Found"; -- RFC7231, Section 6.5.4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
40 [405] = "Method Not Allowed"; -- RFC7231, Section 6.5.5
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
41 [406] = "Not Acceptable"; -- RFC7231, Section 6.5.6
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
42 [407] = "Proxy Authentication Required"; -- RFC7235, Section 3.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
43 [408] = "Request Timeout"; -- RFC7231, Section 6.5.7
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
44 [409] = "Conflict"; -- RFC7231, Section 6.5.8
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
45 [410] = "Gone"; -- RFC7231, Section 6.5.9
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
46 [411] = "Length Required"; -- RFC7231, Section 6.5.10
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
47 [412] = "Precondition Failed"; -- RFC7232, Section 4.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
48 [413] = "Payload Too Large"; -- RFC7231, Section 6.5.11
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
49 [414] = "URI Too Long"; -- RFC7231, Section 6.5.12
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
50 [415] = "Unsupported Media Type"; -- RFC7231, Section 6.5.13
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
51 [416] = "Range Not Satisfiable"; -- RFC7233, Section 4.4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
52 [417] = "Expectation Failed"; -- RFC7231, Section 6.5.14
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
53 [418] = "I'm a teapot"; -- RFC2324, Section 2.3.2
9170
47ffce31ffe4 net.http.codes: "Correct" range of unassigned codes (thanks pep.)
Kim Alvefur <zash@zash.se>
parents: 9167
diff changeset
54 -- [419-420] = "Unassigned";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
55 [421] = "Misdirected Request"; -- RFC7540, Section 9.1.2
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
56 [422] = "Unprocessable Entity";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
57 [423] = "Locked";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
58 [424] = "Failed Dependency";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
59 [425] = "Too Early";
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
60 [426] = "Upgrade Required"; -- RFC7231, Section 6.5.15
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
61 -- [427] = "Unassigned";
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
62 [428] = "Precondition Required";
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
63 [429] = "Too Many Requests";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
64 -- [430] = "Unassigned";
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
65 [431] = "Request Header Fields Too Large";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
66 -- [432-450] = "Unassigned";
7572
f549587b8c06 net.http.codes: Add HTTP status code 451 Unavailable For Legal Reasons from RFC 7725
Kim Alvefur <zash@zash.se>
parents: 7571
diff changeset
67 [451] = "Unavailable For Legal Reasons";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
68 -- [452-499] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
69
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
70 [500] = "Internal Server Error"; -- RFC7231, Section 6.6.1
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
71 [501] = "Not Implemented"; -- RFC7231, Section 6.6.2
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
72 [502] = "Bad Gateway"; -- RFC7231, Section 6.6.3
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
73 [503] = "Service Unavailable"; -- RFC7231, Section 6.6.4
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
74 [504] = "Gateway Timeout"; -- RFC7231, Section 6.6.5
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
75 [505] = "HTTP Version Not Supported"; -- RFC7231, Section 6.6.6
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
76 [506] = "Variant Also Negotiates";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
77 [507] = "Insufficient Storage";
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
78 [508] = "Loop Detected";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
79 -- [509] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
80 [510] = "Not Extended";
6694
fc45dc6d604c net.http.codes: Update from registry
Kim Alvefur <zash@zash.se>
parents: 4723
diff changeset
81 [511] = "Network Authentication Required";
9167
7ed130d3676c net.http.codes: Regenerate from IANA registry with tool
Kim Alvefur <zash@zash.se>
parents: 7572
diff changeset
82 -- [512-599] = "Unassigned";
4631
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
83 };
fc5d3b053454 net.http.{server|codes|parser}: Initial commit.
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
84
10370
78bda7932f17 net.http.codes: Avoid implicit number -> string coercion
Kim Alvefur <zash@zash.se>
parents: 9170
diff changeset
85 for k,v in pairs(response_codes) do response_codes[k] = ("%03d %s"):format(k, v); end
7571
e8efb5cf0877 net.http.codes: Remove used argument
Kim Alvefur <zash@zash.se>
parents: 6694
diff changeset
86 return setmetatable(response_codes, { __index = function(_, k) return k.." Unassigned"; end })