diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-05-13 23:35:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-05-13 23:35:01 +0200 |
commit | d62efd6aaa7a408e04484f26d97b3b74114cc4b6 (patch) | |
tree | 5340aded408bd1f523c35c496fcc81211096c921 | |
parent | 56eafb8f94157eecca4410ff6924715fe8328386 (diff) | |
download | gana-d62efd6aaa7a408e04484f26d97b3b74114cc4b6.tar.gz gana-d62efd6aaa7a408e04484f26d97b3b74114cc4b6.zip |
setup http status code registry
-rw-r--r-- | http-status-codes/Makefile | 31 | ||||
-rw-r--r-- | http-status-codes/README | 7 | ||||
-rwxr-xr-x | http-status-codes/extend.sh | 19 | ||||
-rw-r--r-- | http-status-codes/extras.rec | 13 | ||||
-rw-r--r-- | http-status-codes/h.footer | 13 | ||||
-rw-r--r-- | http-status-codes/h.header | 40 | ||||
-rw-r--r-- | http-status-codes/h.template | 6 | ||||
-rw-r--r-- | http-status-codes/http-status-codes-1.csv | 74 | ||||
-rw-r--r-- | http-status-codes/types.rec | 19 |
9 files changed, 222 insertions, 0 deletions
diff --git a/http-status-codes/Makefile b/http-status-codes/Makefile new file mode 100644 index 0000000..cea962b --- /dev/null +++ b/http-status-codes/Makefile | |||
@@ -0,0 +1,31 @@ | |||
1 | FILES=registry.rec http-status-codes.h | ||
2 | all: check $(FILES) | ||
3 | check: registry.rec | ||
4 | recfix --check registry.rec | ||
5 | |||
6 | # http-status-codes-1.csv is from IANA! | ||
7 | iana.tmp: http-status-codes-1.csv | ||
8 | cat $^ | grep -v Unassigned | csv2rec > $@ | ||
9 | |||
10 | # extend by all-caps descriptions suitable for C-style identifier generation | ||
11 | iana-extended.tmp: iana.tmp | ||
12 | ./extend.sh $@ $^ | ||
13 | |||
14 | registry.rec: types.rec iana-extended.tmp extras.rec | ||
15 | cat $^ > $@ | ||
16 | |||
17 | distclean: | ||
18 | rm -f *.tmp | ||
19 | |||
20 | clean: | ||
21 | rm -f $(FILES) *.tmp | ||
22 | |||
23 | |||
24 | http-status-codes.h.tmp: registry.rec h.template | ||
25 | ../format.sh h.template < registry.rec > $@ | ||
26 | |||
27 | http-status-codes.h: h.header http-status-codes.h.tmp h.footer | ||
28 | cat $^ > $@ | ||
29 | |||
30 | |||
31 | .PHONY: check clean distclean | ||
diff --git a/http-status-codes/README b/http-status-codes/README new file mode 100644 index 0000000..cc1ec53 --- /dev/null +++ b/http-status-codes/README | |||
@@ -0,0 +1,7 @@ | |||
1 | HTTP status code registry. | ||
2 | |||
3 | Based on CSV export of | ||
4 | https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml | ||
5 | |||
6 | Extended with vendor-specific status codes (see extras.rec) and C-style | ||
7 | identifiers suitable for code generation based on the descriptions. | ||
diff --git a/http-status-codes/extend.sh b/http-status-codes/extend.sh new file mode 100755 index 0000000..679d541 --- /dev/null +++ b/http-status-codes/extend.sh | |||
@@ -0,0 +1,19 @@ | |||
1 | #!/bin/sh | ||
2 | # Extend all IANA records with a C-style identifier in all-caps. | ||
3 | set -eu | ||
4 | |||
5 | TARGET="$1" | ||
6 | shift | ||
7 | cat "$@" > ${TARGET} | ||
8 | |||
9 | for n in `seq 100 599` | ||
10 | do | ||
11 | VAL=`recsel -e "Value = $n" -P Description iana.rec || true` | ||
12 | CAPS=`echo ${VAL} | tr [a-z] [A-Z] | tr " -" "__"` | ||
13 | recset -f Identifier -a "${CAPS}" -e "Value = $n" ${TARGET} | ||
14 | done | ||
15 | |||
16 | |||
17 | # Apply fixes for records defined differently by MHD: | ||
18 | recset -f Identifier -s "SWITCH_PROXY" -e "Value = 306" ${TARGET} | ||
19 | recset -f Description -s "Switch proxy (not used)" -e "Value = 306" ${TARGET} | ||
diff --git a/http-status-codes/extras.rec b/http-status-codes/extras.rec new file mode 100644 index 0000000..6251e4a --- /dev/null +++ b/http-status-codes/extras.rec | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | |||
3 | # Record types defined outside of IANA (and supported by GNU libmicrohttpd) | ||
4 | # | ||
5 | Value: 449 | ||
6 | Description: Retry with | ||
7 | Reference: [MS IIS extension] | ||
8 | Identifier: RETRY_WITH | ||
9 | |||
10 | Value: 509 | ||
11 | Description: Bandwidth Limit Exceeded | ||
12 | Reference: [Apache extension] | ||
13 | Identifier: BANDWIDTH_LIMIT_EXCEEDED | ||
diff --git a/http-status-codes/h.footer b/http-status-codes/h.footer new file mode 100644 index 0000000..5d32ee9 --- /dev/null +++ b/http-status-codes/h.footer | |||
@@ -0,0 +1,13 @@ | |||
1 | |||
2 | |||
3 | }; | ||
4 | |||
5 | |||
6 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
7 | { | ||
8 | #endif | ||
9 | #ifdef __cplusplus | ||
10 | } | ||
11 | #endif | ||
12 | |||
13 | #endif | ||
diff --git a/http-status-codes/h.header b/http-status-codes/h.header new file mode 100644 index 0000000..aeb50a3 --- /dev/null +++ b/http-status-codes/h.header | |||
@@ -0,0 +1,40 @@ | |||
1 | /* | ||
2 | This file is part of GNU libmicrohttpd | ||
3 | Copyright (C) 2012-2020 GNUnet e.V. | ||
4 | |||
5 | GNU libmicrohttpd is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Lesser General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNU libmicrohttpd is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: LGPL3.0-or-later | ||
19 | */ | ||
20 | #ifndef GNU_LIBMICROHTTPD_HTTP_STATUS_CODES_H | ||
21 | #define GNU_LIBMICROHTTPD_HTTP_STATUS_CODES_H | ||
22 | |||
23 | #ifdef __cplusplus | ||
24 | extern "C" { | ||
25 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
26 | } | ||
27 | #endif | ||
28 | #endif | ||
29 | |||
30 | |||
31 | /** | ||
32 | * HTTP status codes as per RFC 7231 plus vendor extensions. | ||
33 | * | ||
34 | * 1xx: Informational - Request received, continuing process | ||
35 | * 2xx: Success - The action was successfully received, understood, and accepted | ||
36 | * 3xx: Redirection - Further action must be taken in order to complete the request | ||
37 | * 4xx: Client Error - The request contains bad syntax or cannot be fulfilled | ||
38 | * 5xx: Server Error - The server failed to fulfill an apparently valid request | ||
39 | */ | ||
40 | enum MHD_HTTP_StatusCode { | ||
diff --git a/http-status-codes/h.template b/http-status-codes/h.template new file mode 100644 index 0000000..bb8d339 --- /dev/null +++ b/http-status-codes/h.template | |||
@@ -0,0 +1,6 @@ | |||
1 | |||
2 | |||
3 | /** | ||
4 | * {{Description}} {{Reference}} | ||
5 | */ | ||
6 | MHD_HTTP_{{Identifier}} = {{Value}}, | ||
diff --git a/http-status-codes/http-status-codes-1.csv b/http-status-codes/http-status-codes-1.csv new file mode 100644 index 0000000..9abdcae --- /dev/null +++ b/http-status-codes/http-status-codes-1.csv | |||
@@ -0,0 +1,74 @@ | |||
1 | Value,Description,Reference | ||
2 | 100,Continue,"[RFC7231, Section 6.2.1]" | ||
3 | 101,Switching Protocols,"[RFC7231, Section 6.2.2]" | ||
4 | 102,Processing,[RFC2518] | ||
5 | 103,Early Hints,[RFC8297] | ||
6 | 104-199,Unassigned, | ||
7 | 200,OK,"[RFC7231, Section 6.3.1]" | ||
8 | 201,Created,"[RFC7231, Section 6.3.2]" | ||
9 | 202,Accepted,"[RFC7231, Section 6.3.3]" | ||
10 | 203,Non-Authoritative Information,"[RFC7231, Section 6.3.4]" | ||
11 | 204,No Content,"[RFC7231, Section 6.3.5]" | ||
12 | 205,Reset Content,"[RFC7231, Section 6.3.6]" | ||
13 | 206,Partial Content,"[RFC7233, Section 4.1]" | ||
14 | 207,Multi-Status,[RFC4918] | ||
15 | 208,Already Reported,[RFC5842] | ||
16 | 209-225,Unassigned, | ||
17 | 226,IM Used,[RFC3229] | ||
18 | 227-299,Unassigned, | ||
19 | 300,Multiple Choices,"[RFC7231, Section 6.4.1]" | ||
20 | 301,Moved Permanently,"[RFC7231, Section 6.4.2]" | ||
21 | 302,Found,"[RFC7231, Section 6.4.3]" | ||
22 | 303,See Other,"[RFC7231, Section 6.4.4]" | ||
23 | 304,Not Modified,"[RFC7232, Section 4.1]" | ||
24 | 305,Use Proxy,"[RFC7231, Section 6.4.5]" | ||
25 | 306,(Unused),"[RFC7231, Section 6.4.6]" | ||
26 | 307,Temporary Redirect,"[RFC7231, Section 6.4.7]" | ||
27 | 308,Permanent Redirect,[RFC7538] | ||
28 | 309-399,Unassigned, | ||
29 | 400,Bad Request,"[RFC7231, Section 6.5.1]" | ||
30 | 401,Unauthorized,"[RFC7235, Section 3.1]" | ||
31 | 402,Payment Required,"[RFC7231, Section 6.5.2]" | ||
32 | 403,Forbidden,"[RFC7231, Section 6.5.3]" | ||
33 | 404,Not Found,"[RFC7231, Section 6.5.4]" | ||
34 | 405,Method Not Allowed,"[RFC7231, Section 6.5.5]" | ||
35 | 406,Not Acceptable,"[RFC7231, Section 6.5.6]" | ||
36 | 407,Proxy Authentication Required,"[RFC7235, Section 3.2]" | ||
37 | 408,Request Timeout,"[RFC7231, Section 6.5.7]" | ||
38 | 409,Conflict,"[RFC7231, Section 6.5.8]" | ||
39 | 410,Gone,"[RFC7231, Section 6.5.9]" | ||
40 | 411,Length Required,"[RFC7231, Section 6.5.10]" | ||
41 | 412,Precondition Failed,"[RFC7232, Section 4.2][RFC8144, Section 3.2]" | ||
42 | 413,Payload Too Large,"[RFC7231, Section 6.5.11]" | ||
43 | 414,URI Too Long,"[RFC7231, Section 6.5.12]" | ||
44 | 415,Unsupported Media Type,"[RFC7231, Section 6.5.13][RFC7694, Section 3]" | ||
45 | 416,Range Not Satisfiable,"[RFC7233, Section 4.4]" | ||
46 | 417,Expectation Failed,"[RFC7231, Section 6.5.14]" | ||
47 | 418-420,Unassigned, | ||
48 | 421,Misdirected Request,"[RFC7540, Section 9.1.2]" | ||
49 | 422,Unprocessable Entity,[RFC4918] | ||
50 | 423,Locked,[RFC4918] | ||
51 | 424,Failed Dependency,[RFC4918] | ||
52 | 425,Too Early,[RFC8470] | ||
53 | 426,Upgrade Required,"[RFC7231, Section 6.5.15]" | ||
54 | 427,Unassigned, | ||
55 | 428,Precondition Required,[RFC6585] | ||
56 | 429,Too Many Requests,[RFC6585] | ||
57 | 430,Unassigned, | ||
58 | 431,Request Header Fields Too Large,[RFC6585] | ||
59 | 432-450,Unassigned, | ||
60 | 451,Unavailable For Legal Reasons,[RFC7725] | ||
61 | 452-499,Unassigned, | ||
62 | 500,Internal Server Error,"[RFC7231, Section 6.6.1]" | ||
63 | 501,Not Implemented,"[RFC7231, Section 6.6.2]" | ||
64 | 502,Bad Gateway,"[RFC7231, Section 6.6.3]" | ||
65 | 503,Service Unavailable,"[RFC7231, Section 6.6.4]" | ||
66 | 504,Gateway Timeout,"[RFC7231, Section 6.6.5]" | ||
67 | 505,HTTP Version Not Supported,"[RFC7231, Section 6.6.6]" | ||
68 | 506,Variant Also Negotiates,[RFC2295] | ||
69 | 507,Insufficient Storage,[RFC4918] | ||
70 | 508,Loop Detected,[RFC5842] | ||
71 | 509,Unassigned, | ||
72 | 510,Not Extended,[RFC2774] | ||
73 | 511,Network Authentication Required,[RFC6585] | ||
74 | 512-599,Unassigned, | ||
diff --git a/http-status-codes/types.rec b/http-status-codes/types.rec new file mode 100644 index 0000000..431a9b1 --- /dev/null +++ b/http-status-codes/types.rec | |||
@@ -0,0 +1,19 @@ | |||
1 | # -*- mode: rec -*- | ||
2 | # | ||
3 | # Registry for HTTP status codes | ||
4 | # | ||
5 | %rec: HttpStatusCode | ||
6 | %key: Value | ||
7 | %typedef: ValueRange_t range 100 599 | ||
8 | %type: Value ValueRange_t | ||
9 | %mandatory: Value | ||
10 | %typedef: Description_t regexp /^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-][abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_\(\) -]*$/ | ||
11 | %type: Description Description_t | ||
12 | %unique: Description | ||
13 | %mandatory: Description | ||
14 | %typedef: Identifier_t regexp /^[ABCDEFGHIJKLMNOPQRSTUVWXYZ_][ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]*$/ | ||
15 | %type: Identifier Identifier_t | ||
16 | %unique: Identifier | ||
17 | %mandatory: Identifier | ||
18 | %allowed: Reference | ||
19 | %sort: Number | ||