libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 56827b9b7acb7927451c5b81e9637134cfb13e98
parent 63fdb091c85ee4dc9307f7dde53564c257e2182b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat,  8 Jun 2019 15:08:51 +0300

contrib: published scripts for updating MHD header with new HTTP methods and headers

Diffstat:
Acontrib/gen_http_headers_insert.sh | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acontrib/gen_http_methods_insert.sh | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+), 0 deletions(-)

diff --git a/contrib/gen_http_headers_insert.sh b/contrib/gen_http_headers_insert.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Generate header insert for HTTP headers +# + +# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) <k2k@yandex.ru> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +wget -nv http://www.iana.org/assignments/message-headers/perm-headers.csv -O perm-headers.csv || exit +echo Generating... +echo '/** + * @defgroup headers HTTP headers + * These are the standard headers found in HTTP requests and responses. + * See: http://www.iana.org/assignments/message-headers/message-headers.xml + * Registry export date: '$(date -u +%Y-%m-%d)' + * @{ + */ + +/* Main HTTP headers. */' > header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +{ + if ($3 == "http") { + gsub(/^\[|^"\[|\]"$|\]$/, "", $5) + rfc_num = substr($5, 4, 4) + if (rfc_num >= 7230 && rfc_num <= 7235) + { + gsub(/\]\[/, "; ", $5) + if (length($4) == 0) + { $4 = "No category" } + else + { sub(/^./, toupper(substr($4, 1, 1)), $4) } + print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */" + print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" + } + } +}' perm-headers.csv >> header_insert_headers.h && \ +echo ' +/* Additional HTTP headers. */' >> header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +{ + if ($3 == "http") { + gsub(/^\[|^"\[|\]"$|\]$/, "", $5) + rfc_num = substr($5, 4, 4) + if (!(rfc_num >= 7230 && rfc_num <= 7235)) + { + gsub(/\]\[/, "; ", $5) + if (length($4) == 0) + { $4 = "No category" } + else + { sub(/^./, toupper(substr($4, 1, 1)), $4) } + print "/* " sprintf("%-14.14s", $4 ".") " " $5 " */" + print "#define MHD_HTTP_HEADER_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" + } + } +}' perm-headers.csv >> header_insert_headers.h && \ +echo OK && \ +rm perm-headers.csv || exit diff --git a/contrib/gen_http_methods_insert.sh b/contrib/gen_http_methods_insert.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# Generate header insert for HTTP methods +# + +# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) <k2k@yandex.ru> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +wget -nv http://www.iana.org/assignments/http-methods/methods.csv -O methods.csv || exit +echo Generating... +echo '/** + * @defgroup methods HTTP methods + * HTTP methods (as strings). + * See: http://www.iana.org/assignments/http-methods/http-methods.xml + * Registry export date: '$(date -u +%Y-%m-%d)' + * @{ + */ + +/* Main HTTP methods. */' > header_insert_methods.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + gsub(/\]\[/, "; ", $4) + if (substr($4, 1, 7) == "RFC7231") { + if ($2 == "yes") + { safe_m = "Safe. " } + else + { safe_m = "Not safe." } + if ($3 == "yes") + { indem_m = "Idempotent. " } + else + { indem_m = "Not idempotent." } + print "/* " safe_m " " indem_m " " $4 ". */" + print "#define MHD_HTTP_METHOD_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" + } +}' methods.csv >> header_insert_methods.h && \ +echo ' +/* Additional HTTP methods. */' >> header_insert_methods.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + gsub(/\]\[/, "; ", $4) + if (substr($4, 1, 7) != "RFC7231") { + if ($2 == "yes") + { safe_m = "Safe. " } + else + { safe_m = "Not safe." } + if ($3 == "yes") + { indem_m = "Idempotent. " } + else + { indem_m = "Not idempotent." } + print "/* " safe_m " " indem_m " " $4 ". */" + print "#define MHD_HTTP_METHOD_" toupper(gensub(/-/, "_", "g", $1)) " \""$1"\"" + } +}' methods.csv >> header_insert_methods.h && \ +echo OK && \ +rm methods.csv || exit