From 73104a4b592bac1f113aced71f4acb7f9731f06c Mon Sep 17 00:00:00 2001 From: Igor Galarraga Date: Tue, 5 Nov 2019 00:01:08 +0100 Subject: [PATCH] Process all method like POST (with body). Originally this example: curl -v -XGET --data 'test' 'http://localhost:8080/service' does not finalize connection with client. With this change, connection closes and responds correctly. --- src/webserver.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/webserver.cpp b/src/webserver.cpp index a0608f95..83d6022d 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -776,8 +776,6 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection, base_unescaper(t_url, static_cast(cls)->unescaper); mr->standardized_url = new string(http_utils::standardize_url(t_url)); - bool body = false; - access_log( static_cast(cls), *(mr->complete_uri) + " METHOD: " + method @@ -790,22 +788,18 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection, else if (0 == strcmp(method, http_utils::http_method_post.c_str())) { mr->callback = &http_resource::render_POST; - body = true; } else if (0 == strcasecmp(method, http_utils::http_method_put.c_str())) { mr->callback = &http_resource::render_PUT; - body = true; } else if (0 == strcasecmp(method,http_utils::http_method_delete.c_str())) { mr->callback = &http_resource::render_DELETE; - body = true; } else if (0 == strcasecmp(method, http_utils::http_method_patch.c_str())) { mr->callback = &http_resource::render_PATCH; - body = true; } else if (0 == strcasecmp(method, http_utils::http_method_head.c_str())) { @@ -824,7 +818,7 @@ int webserver::answer_to_connection(void* cls, MHD_Connection* connection, mr->callback = &http_resource::render_OPTIONS; } - return body ? static_cast(cls)->bodyfull_requests_answer_first_step(connection, mr) : static_cast(cls)->bodyless_requests_answer(connection, method, version, mr); + return static_cast(cls)->bodyfull_requests_answer_first_step(connection, mr); } };