From 50b44dcf9e1ad2d8865324c404271319916e2d4e Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Sat, 30 Oct 2021 16:25:49 +0300 Subject: Updated HTTP headers names --- contrib/gen_http_headers_insert.sh | 129 ++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 29 deletions(-) (limited to 'contrib') 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 @@ # Generate header insert for HTTP headers # -# Copyright (c) 2015-2019 Karlson2k (Evgeny Grin) +# Copyright (c) 2015-2021 Karlson2k (Evgeny Grin) # # 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 +wget -nv https://www.iana.org/assignments/http-fields/field-names.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)' + * See: https://www.iana.org/assignments/http-fields/http-fields.xhtml + * 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) +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" == substr(ref, 1, 16)) { - gsub(/\]\[/, "; ", $5) - if (length($4) == 0) - { $4 = "No category" } + gsub(/\]\[/, "; ", ref) + if (length(status) == 0) + { status = "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"\"" + { sub(/^./, toupper(substr(status, 1, 1)), status) } + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $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)) +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "permanent") { - 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"\"" + gsub(/\]\[/, "; ", ref) + sub(/^./, toupper(substr(status, 1, 1)), status) + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1) + } +}' perm-headers.csv >> header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "provisional") + { + gsub(/\]\[/, "; ", ref) + sub(/^./, toupper(substr(status, 1, 1)), status) + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1) + } +}' perm-headers.csv >> header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && length(status) == 0) + { + gsub(/\]\[/, "; ", ref) + status = "No category" + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1) + } +}' perm-headers.csv >> header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "deprecated") + { + gsub(/\]\[/, "; ", ref) + sub(/^./, toupper(substr(status, 1, 1)), status) + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1) + } +}' perm-headers.csv >> header_insert_headers.h && \ +gawk -e 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} +FNR > 1 { + gsub(/^\[|^"\[|\]"$|\]$/, "", $4) + field_name = $1 + status = $3 + ref = $4 + comment = $5 + if ("RFC-ietf-httpbis" != substr(ref, 1, 16) && status == "obsoleted") + { + gsub(/\]\[/, "; ", ref) + sub(/^./, toupper(substr(status, 1, 1)), status) + field_name = gensub(/\*/, "ASTERISK", "g", field_name) + field_name = gensub(/[^a-zA-Z0-9_]/, "_", "g", field_name) + printf ("/* %-14.14s %s */\n", status ".", ref) + printf ("#define MHD_HTTP_HEADER_%-12s \"%s\"\n", toupper(field_name), $1) } - } }' perm-headers.csv >> header_insert_headers.h && \ echo OK && \ rm perm-headers.csv || exit -- cgit v1.2.3