aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-10-30 16:25:49 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-10-30 16:49:46 +0300
commit50b44dcf9e1ad2d8865324c404271319916e2d4e (patch)
treee52da3530ce581f7b4c1cf55a7792b4015cb0be5 /contrib
parentaed886a2618e68f4ec08ad42ae31d17df1706910 (diff)
downloadlibmicrohttpd-50b44dcf9e1ad2d8865324c404271319916e2d4e.tar.gz
libmicrohttpd-50b44dcf9e1ad2d8865324c404271319916e2d4e.zip
Updated HTTP headers names
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gen_http_headers_insert.sh129
1 files changed, 100 insertions, 29 deletions
diff --git a/contrib/gen_http_headers_insert.sh b/contrib/gen_http_headers_insert.sh
index 6fce2809..d373045e 100755
--- a/contrib/gen_http_headers_insert.sh
+++ b/contrib/gen_http_headers_insert.sh
@@ -4,59 +4,130 @@
4# Generate header insert for HTTP headers 4# Generate header insert for HTTP headers
5# 5#
6 6
7# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) <k2k@yandex.ru> 7# Copyright (c) 2015-2021 Karlson2k (Evgeny Grin) <k2k@yandex.ru>
8# 8#
9# Copying and distribution of this file, with or without modification, are 9# Copying and distribution of this file, with or without modification, are
10# permitted in any medium without royalty provided the copyright notice 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 11# and this notice are preserved. This file is offered as-is, without any
12# warranty. 12# warranty.
13 13
14wget -nv http://www.iana.org/assignments/message-headers/perm-headers.csv -O perm-headers.csv || exit 14wget -nv https://www.iana.org/assignments/http-fields/field-names.csv -O perm-headers.csv || exit
15echo Generating... 15echo Generating...
16echo '/** 16echo '/**
17 * @defgroup headers HTTP headers 17 * @defgroup headers HTTP headers
18 * These are the standard headers found in HTTP requests and responses. 18 * These are the standard headers found in HTTP requests and responses.
19 * See: http://www.iana.org/assignments/message-headers/message-headers.xml 19 * See: https://www.iana.org/assignments/http-fields/http-fields.xhtml
20 * Registry export date: '$(date -u +%Y-%m-%d)' 20 * Registry export date: '"$(date -u +%Y-%m-%d)"'
21 * @{ 21 * @{
22 */ 22 */
23 23
24/* Main HTTP headers. */' > header_insert_headers.h && \ 24/* Main HTTP headers. */' > header_insert_headers.h && \
25gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} 25gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
26{ 26FNR > 1 {
27 if ($3 == "http") { 27 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
28 gsub(/^\[|^"\[|\]"$|\]$/, "", $5) 28 field_name = $1
29 rfc_num = substr($5, 4, 4) 29 status = $3
30 if (rfc_num >= 7230 && rfc_num <= 7235) 30 ref = $4
31 comment = $5
32 if ("RFC-ietf-httpbis" == substr(ref, 1, 16))
31 { 33 {
32 gsub(/\]\[/, "; ", $5) 34 gsub(/\]\[/, "; ", ref)
33 if (length($4) == 0) 35 if (length(status) == 0)
34 { $4 = "No category" } 36 { status = "No category" }
35 else 37 else
36 { sub(/^./, toupper(substr($4, 1, 1)), $4) } 38 { sub(/^./, toupper(substr(status, 1, 1)), status) }
37 print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */" 39 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
38 print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" 40 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
41 printf ("/* %-14.14s %s */\n", status ".", ref)
42 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
39 } 43 }
40 }
41}' perm-headers.csv >> header_insert_headers.h && \ 44}' perm-headers.csv >> header_insert_headers.h && \
42echo ' 45echo '
43/* Additional HTTP headers. */' >> header_insert_headers.h && \ 46/* Additional HTTP headers. */' >> header_insert_headers.h && \
44gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} 47gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
45{ 48FNR > 1 {
46 if ($3 == "http") { 49 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
47 gsub(/^\[|^"\[|\]"$|\]$/, "", $5) 50 field_name = $1
48 rfc_num = substr($5, 4, 4) 51 status = $3
49 if (!(rfc_num >= 7230 && rfc_num <= 7235)) 52 ref = $4
53 comment = $5
54 if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "permanent")
50 { 55 {
51 gsub(/\]\[/, "; ", $5) 56 gsub(/\]\[/, "; ", ref)
52 if (length($4) == 0) 57 sub(/^./, toupper(substr(status, 1, 1)), status)
53 { $4 = "No category" } 58 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
54 else 59 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
55 { sub(/^./, toupper(substr($4, 1, 1)), $4) } 60 printf ("/* %-14.14s %s */\n", status ".", ref)
56 print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */" 61 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
57 print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" 62 }
63}' perm-headers.csv >> header_insert_headers.h && \
64gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
65FNR > 1 {
66 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
67 field_name = $1
68 status = $3
69 ref = $4
70 comment = $5
71 if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "provisional")
72 {
73 gsub(/\]\[/, "; ", ref)
74 sub(/^./, toupper(substr(status, 1, 1)), status)
75 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
76 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
77 printf ("/* %-14.14s %s */\n", status ".", ref)
78 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
79 }
80}' perm-headers.csv >> header_insert_headers.h && \
81gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
82FNR > 1 {
83 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
84 field_name = $1
85 status = $3
86 ref = $4
87 comment = $5
88 if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && length(status) == 0)
89 {
90 gsub(/\]\[/, "; ", ref)
91 status = "No category"
92 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
93 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
94 printf ("/* %-14.14s %s */\n", status ".", ref)
95 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
96 }
97}' perm-headers.csv >> header_insert_headers.h && \
98gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
99FNR > 1 {
100 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
101 field_name = $1
102 status = $3
103 ref = $4
104 comment = $5
105 if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "deprecated")
106 {
107 gsub(/\]\[/, "; ", ref)
108 sub(/^./, toupper(substr(status, 1, 1)), status)
109 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
110 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
111 printf ("/* %-14.14s %s */\n", status ".", ref)
112 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
113 }
114}' perm-headers.csv >> header_insert_headers.h && \
115gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"}
116FNR > 1 {
117 gsub(/^\[|^"\[|\]"$|\]$/, "", $4)
118 field_name = $1
119 status = $3
120 ref = $4
121 comment = $5
122 if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "obsoleted")
123 {
124 gsub(/\]\[/, "; ", ref)
125 sub(/^./, toupper(substr(status, 1, 1)), status)
126 field_name = gensub(/\*/, "ASTERISK", "g", field_name)
127 field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name)
128 printf ("/* %-14.14s %s */\n", status ".", ref)
129 printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1)
58 } 130 }
59 }
60}' perm-headers.csv >> header_insert_headers.h && \ 131}' perm-headers.csv >> header_insert_headers.h && \
61echo OK && \ 132echo OK && \
62rm perm-headers.csv || exit 133rm perm-headers.csv || exit