aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-08 15:08:51 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2019-06-09 12:14:27 +0300
commit56827b9b7acb7927451c5b81e9637134cfb13e98 (patch)
treead8cb963b4c5b136b35b8fc6af818bbee61d6732 /contrib
parent63fdb091c85ee4dc9307f7dde53564c257e2182b (diff)
downloadlibmicrohttpd-56827b9b7acb7927451c5b81e9637134cfb13e98.tar.gz
libmicrohttpd-56827b9b7acb7927451c5b81e9637134cfb13e98.zip
contrib: published scripts for updating MHD header with new HTTP methods and headers
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gen_http_headers_insert.sh62
-rwxr-xr-xcontrib/gen_http_methods_insert.sh62
2 files changed, 124 insertions, 0 deletions
diff --git a/contrib/gen_http_headers_insert.sh b/contrib/gen_http_headers_insert.sh
new file mode 100755
index 00000000..6fce2809
--- /dev/null
+++ b/contrib/gen_http_headers_insert.sh
@@ -0,0 +1,62 @@
1#!/bin/bash
2
3#
4# Generate header insert for HTTP headers
5#
6
7# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) <k2k@yandex.ru>
8#
9# Copying and distribution of this file, with or without modification, are
10# permitted in any medium without royalty provided the copyright notice
11# and this notice are preserved. This file is offered as-is, without any
12# warranty.
13
14wget -nv http://www.iana.org/assignments/message-headers/perm-headers.csv -O perm-headers.csv || exit
15echo Generating...
16echo '/**
17 * @defgroup headers HTTP headers
18 * These are the standard headers found in HTTP requests and responses.
19 * See: http://www.iana.org/assignments/message-headers/message-headers.xml
20 * Registry export date: '$(date -u +%Y-%m-%d)'
21 * @{
22 */
23
24/* Main HTTP headers. */' > header_insert_headers.h && \
25gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
26{
27 if ($3 == "http") {
28 gsub(/^\[|^"\[|\]"$|\]$/, "", $5)
29 rfc_num = substr($5, 4, 4)
30 if (rfc_num >= 7230 && rfc_num <= 7235)
31 {
32 gsub(/\]\[/, "; ", $5)
33 if (length($4) == 0)
34 { $4 = "No category" }
35 else
36 { sub(/^./, toupper(substr($4, 1, 1)), $4) }
37 print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */"
38 print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\""
39 }
40 }
41}' perm-headers.csv >> header_insert_headers.h && \
42echo '
43/* Additional HTTP headers. */' >> header_insert_headers.h && \
44gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
45{
46 if ($3 == "http") {
47 gsub(/^\[|^"\[|\]"$|\]$/, "", $5)
48 rfc_num = substr($5, 4, 4)
49 if (!(rfc_num >= 7230 && rfc_num <= 7235))
50 {
51 gsub(/\]\[/, "; ", $5)
52 if (length($4) == 0)
53 { $4 = "No category" }
54 else
55 { sub(/^./, toupper(substr($4, 1, 1)), $4) }
56 print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */"
57 print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\""
58 }
59 }
60}' perm-headers.csv >> header_insert_headers.h && \
61echo OK && \
62rm perm-headers.csv || exit
diff --git a/contrib/gen_http_methods_insert.sh b/contrib/gen_http_methods_insert.sh
new file mode 100755
index 00000000..38485848
--- /dev/null
+++ b/contrib/gen_http_methods_insert.sh
@@ -0,0 +1,62 @@
1#!/bin/bash
2
3#
4# Generate header insert for HTTP methods
5#
6
7# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) <k2k@yandex.ru>
8#
9# Copying and distribution of this file, with or without modification, are
10# permitted in any medium without royalty provided the copyright notice
11# and this notice are preserved. This file is offered as-is, without any
12# warranty.
13
14wget -nv http://www.iana.org/assignments/http-methods/methods.csv -O methods.csv || exit
15echo Generating...
16echo '/**
17 * @defgroup methods HTTP methods
18 * HTTP methods (as strings).
19 * See: http://www.iana.org/assignments/http-methods/http-methods.xml
20 * Registry export date: '$(date -u +%Y-%m-%d)'
21 * @{
22 */
23
24/* Main HTTP methods. */' > header_insert_methods.h && \
25gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
26FNR > 1 {
27 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
28 gsub(/\]\[/, "; ", $4)
29 if (substr($4, 1, 7) == "RFC7231") {
30 if ($2 == "yes")
31 { safe_m = "Safe. " }
32 else
33 { safe_m = "Not safe." }
34 if ($3 == "yes")
35 { indem_m = "Idempotent. " }
36 else
37 { indem_m = "Not idempotent." }
38 print "/* " safe_m " " indem_m " " $4 ". */"
39 print "#define MHD_HTTP_METHOD_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\""
40 }
41}' methods.csv >> header_insert_methods.h && \
42echo '
43/* Additional HTTP methods. */' >> header_insert_methods.h && \
44gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
45FNR > 1 {
46 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
47 gsub(/\]\[/, "; ", $4)
48 if (substr($4, 1, 7) != "RFC7231") {
49 if ($2 == "yes")
50 { safe_m = "Safe. " }
51 else
52 { safe_m = "Not safe." }
53 if ($3 == "yes")
54 { indem_m = "Idempotent. " }
55 else
56 { indem_m = "Not idempotent." }
57 print "/* " safe_m " " indem_m " " $4 ". */"
58 print "#define MHD_HTTP_METHOD_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\""
59 }
60}' methods.csv >> header_insert_methods.h && \
61echo OK && \
62rm methods.csv || exit