From 4026e64c3280ad2f2b642703c96456cc0130beb5 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Wed, 11 Dec 2024 14:31:15 +0530 Subject: [PATCH] feat(esp_http_server): add support to handle HTTP 1.0 requests This commit adds support to handle HTTP/1.0 requests alongside HTTP/1.1 for legacy compliance purposes. --- components/esp_http_server/include/esp_http_server.h | 2 +- components/esp_http_server/src/httpd_parse.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_http_server/include/esp_http_server.h b/components/esp_http_server/include/esp_http_server.h index 759eadf85f6f..622d93fb72d4 100644 --- a/components/esp_http_server/include/esp_http_server.h +++ b/components/esp_http_server/include/esp_http_server.h @@ -569,7 +569,7 @@ typedef enum { */ HTTPD_501_METHOD_NOT_IMPLEMENTED, - /* When HTTP version is not 1.1 */ + /* When HTTP version is not 1.1 or 1.0*/ HTTPD_505_VERSION_NOT_SUPPORTED, /* Returned when http_parser halts parsing due to incorrect diff --git a/components/esp_http_server/src/httpd_parse.c b/components/esp_http_server/src/httpd_parse.c index 2fbc37f3eb82..9cd2e26f0a61 100644 --- a/components/esp_http_server/src/httpd_parse.c +++ b/components/esp_http_server/src/httpd_parse.c @@ -85,8 +85,8 @@ static esp_err_t verify_url (http_parser *parser) strlcpy((char *)r->uri, at, (length + 1)); ESP_LOGD(TAG, LOG_FMT("received URI = %s"), r->uri); - /* Make sure version is HTTP/1.1 */ - if (!((parser->http_major == 1) && (parser->http_minor == 1))) { + /* Make sure version is HTTP/1.1 or HTTP/1.0 (legacy compliance purpose) */ + if (!((parser->http_major == 1) && ((parser->http_minor == 0) || (parser->http_minor == 1)))) { ESP_LOGW(TAG, LOG_FMT("unsupported HTTP version = %d.%d"), parser->http_major, parser->http_minor); parser_data->error = HTTPD_505_VERSION_NOT_SUPPORTED;