aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-13 23:35:01 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-13 23:35:01 +0200
commitd62efd6aaa7a408e04484f26d97b3b74114cc4b6 (patch)
tree5340aded408bd1f523c35c496fcc81211096c921
parent56eafb8f94157eecca4410ff6924715fe8328386 (diff)
downloadgana-d62efd6aaa7a408e04484f26d97b3b74114cc4b6.tar.gz
gana-d62efd6aaa7a408e04484f26d97b3b74114cc4b6.zip
setup http status code registry
-rw-r--r--http-status-codes/Makefile31
-rw-r--r--http-status-codes/README7
-rwxr-xr-xhttp-status-codes/extend.sh19
-rw-r--r--http-status-codes/extras.rec13
-rw-r--r--http-status-codes/h.footer13
-rw-r--r--http-status-codes/h.header40
-rw-r--r--http-status-codes/h.template6
-rw-r--r--http-status-codes/http-status-codes-1.csv74
-rw-r--r--http-status-codes/types.rec19
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 @@
1FILES=registry.rec http-status-codes.h
2all: check $(FILES)
3check: registry.rec
4 recfix --check registry.rec
5
6# http-status-codes-1.csv is from IANA!
7iana.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
11iana-extended.tmp: iana.tmp
12 ./extend.sh $@ $^
13
14registry.rec: types.rec iana-extended.tmp extras.rec
15 cat $^ > $@
16
17distclean:
18 rm -f *.tmp
19
20clean:
21 rm -f $(FILES) *.tmp
22
23
24http-status-codes.h.tmp: registry.rec h.template
25 ../format.sh h.template < registry.rec > $@
26
27http-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 @@
1HTTP status code registry.
2
3Based on CSV export of
4https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
5
6Extended with vendor-specific status codes (see extras.rec) and C-style
7identifiers 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.
3set -eu
4
5TARGET="$1"
6shift
7cat "$@" > ${TARGET}
8
9for n in `seq 100 599`
10do
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}
14done
15
16
17# Apply fixes for records defined differently by MHD:
18recset -f Identifier -s "SWITCH_PROXY" -e "Value = 306" ${TARGET}
19recset -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#
5Value: 449
6Description: Retry with
7Reference: [MS IIS extension]
8Identifier: RETRY_WITH
9
10Value: 509
11Description: Bandwidth Limit Exceeded
12Reference: [Apache extension]
13Identifier: 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
24extern "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 */
40enum 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 @@
1Value,Description,Reference
2100,Continue,"[RFC7231, Section 6.2.1]"
3101,Switching Protocols,"[RFC7231, Section 6.2.2]"
4102,Processing,[RFC2518]
5103,Early Hints,[RFC8297]
6104-199,Unassigned,
7200,OK,"[RFC7231, Section 6.3.1]"
8201,Created,"[RFC7231, Section 6.3.2]"
9202,Accepted,"[RFC7231, Section 6.3.3]"
10203,Non-Authoritative Information,"[RFC7231, Section 6.3.4]"
11204,No Content,"[RFC7231, Section 6.3.5]"
12205,Reset Content,"[RFC7231, Section 6.3.6]"
13206,Partial Content,"[RFC7233, Section 4.1]"
14207,Multi-Status,[RFC4918]
15208,Already Reported,[RFC5842]
16209-225,Unassigned,
17226,IM Used,[RFC3229]
18227-299,Unassigned,
19300,Multiple Choices,"[RFC7231, Section 6.4.1]"
20301,Moved Permanently,"[RFC7231, Section 6.4.2]"
21302,Found,"[RFC7231, Section 6.4.3]"
22303,See Other,"[RFC7231, Section 6.4.4]"
23304,Not Modified,"[RFC7232, Section 4.1]"
24305,Use Proxy,"[RFC7231, Section 6.4.5]"
25306,(Unused),"[RFC7231, Section 6.4.6]"
26307,Temporary Redirect,"[RFC7231, Section 6.4.7]"
27308,Permanent Redirect,[RFC7538]
28309-399,Unassigned,
29400,Bad Request,"[RFC7231, Section 6.5.1]"
30401,Unauthorized,"[RFC7235, Section 3.1]"
31402,Payment Required,"[RFC7231, Section 6.5.2]"
32403,Forbidden,"[RFC7231, Section 6.5.3]"
33404,Not Found,"[RFC7231, Section 6.5.4]"
34405,Method Not Allowed,"[RFC7231, Section 6.5.5]"
35406,Not Acceptable,"[RFC7231, Section 6.5.6]"
36407,Proxy Authentication Required,"[RFC7235, Section 3.2]"
37408,Request Timeout,"[RFC7231, Section 6.5.7]"
38409,Conflict,"[RFC7231, Section 6.5.8]"
39410,Gone,"[RFC7231, Section 6.5.9]"
40411,Length Required,"[RFC7231, Section 6.5.10]"
41412,Precondition Failed,"[RFC7232, Section 4.2][RFC8144, Section 3.2]"
42413,Payload Too Large,"[RFC7231, Section 6.5.11]"
43414,URI Too Long,"[RFC7231, Section 6.5.12]"
44415,Unsupported Media Type,"[RFC7231, Section 6.5.13][RFC7694, Section 3]"
45416,Range Not Satisfiable,"[RFC7233, Section 4.4]"
46417,Expectation Failed,"[RFC7231, Section 6.5.14]"
47418-420,Unassigned,
48421,Misdirected Request,"[RFC7540, Section 9.1.2]"
49422,Unprocessable Entity,[RFC4918]
50423,Locked,[RFC4918]
51424,Failed Dependency,[RFC4918]
52425,Too Early,[RFC8470]
53426,Upgrade Required,"[RFC7231, Section 6.5.15]"
54427,Unassigned,
55428,Precondition Required,[RFC6585]
56429,Too Many Requests,[RFC6585]
57430,Unassigned,
58431,Request Header Fields Too Large,[RFC6585]
59432-450,Unassigned,
60451,Unavailable For Legal Reasons,[RFC7725]
61452-499,Unassigned,
62500,Internal Server Error,"[RFC7231, Section 6.6.1]"
63501,Not Implemented,"[RFC7231, Section 6.6.2]"
64502,Bad Gateway,"[RFC7231, Section 6.6.3]"
65503,Service Unavailable,"[RFC7231, Section 6.6.4]"
66504,Gateway Timeout,"[RFC7231, Section 6.6.5]"
67505,HTTP Version Not Supported,"[RFC7231, Section 6.6.6]"
68506,Variant Also Negotiates,[RFC2295]
69507,Insufficient Storage,[RFC4918]
70508,Loop Detected,[RFC5842]
71509,Unassigned,
72510,Not Extended,[RFC2774]
73511,Network Authentication Required,[RFC6585]
74512-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