From 7b8d7de4d8ca197f2066f13710de87e0597a9804 Mon Sep 17 00:00:00 2001 From: martinhsv <55407942+martinhsv@users.noreply.github.com> Date: Fri, 2 Oct 2020 13:28:05 -0700 Subject: [PATCH] Support http protocol versions besides 0.9, 1.0, 1.1, 2.0 --- CHANGES | 2 ++ src/ngx_http_modsecurity_rewrite.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b7716ef..1f9c852 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ v1.0.x - YYYY-MMM-DD (To be released) ------------------------------------- + - Support http protocol versions besides 0.9, 1.0, 1.1, 2.0 + [Issue #224 - @HQuest, @martinhsv] - Fix nginx not clearing body cache (caused by incomplete fix for #187) [Issue #216 - @krewi1, @martinhsv] - Fix config setting not respected: client_body_in_file_only on diff --git a/src/ngx_http_modsecurity_rewrite.c b/src/ngx_http_modsecurity_rewrite.c index b6a6d6c..4461e02 100644 --- a/src/ngx_http_modsecurity_rewrite.c +++ b/src/ngx_http_modsecurity_rewrite.c @@ -137,7 +137,15 @@ ngx_http_modsecurity_rewrite_handler(ngx_http_request_t *r) break; #endif default : - http_version = "1.0"; + http_version = ngx_str_to_char(r->http_protocol, r->pool); + if (http_version == (char*)-1) { + return NGX_HTTP_INTERNAL_SERVER_ERROR; + } + if ((http_version != NULL) && (strlen(http_version) > 5) && (!strncmp("HTTP/", http_version, 5))) { + http_version += 5; + } else { + http_version = "1.0"; + } break; }