From f59abfc9be6018ceab2ea59a819ac22b8802eeac Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 18 Oct 2016 13:46:32 +0100 Subject: [PATCH] [Fix] Fix HTTP methods other than GET and POST --- contrib/http-parser/http_parser.h | 5 +++-- src/libutil/http.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/contrib/http-parser/http_parser.h b/contrib/http-parser/http_parser.h index bac517f51e..7929315885 100644 --- a/contrib/http-parser/http_parser.h +++ b/contrib/http-parser/http_parser.h @@ -112,7 +112,8 @@ typedef int (*http_cb) (http_parser*); XX(25, PURGE, PURGE) \ /* SPAMC compatibility */ \ XX(26, SYMBOLS, SYMBOLS) \ - XX(27, CHECK, CHECK) + XX(27, CHECK, CHECK) \ + XX(-1, INVALID, INVALID) \ enum http_method { @@ -137,7 +138,7 @@ enum flags /* Map for errno-related constants - * + * * The provided argument should be a macro that takes 2 arguments. */ #define HTTP_ERRNO_MAP(XX) \ diff --git a/src/libutil/http.c b/src/libutil/http.c index a76ab188e1..0df6f190da 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1961,13 +1961,19 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn pbody = NULL; bodylen = 0; priv->outlen = 2; - msg->method = HTTP_GET; + + if (msg->method == HTTP_INVALID) { + msg->method = HTTP_GET; + } } else { pbody = (gchar *)msg->body_buf.begin; bodylen = msg->body_buf.len; priv->outlen = 3; - msg->method = HTTP_POST; + + if (msg->method == HTTP_INVALID) { + msg->method = HTTP_POST; + } } } else if (msg->body_buf.len > 0) { @@ -2175,7 +2181,7 @@ rspamd_http_new_message (enum http_parser_type type) new->port = 80; new->type = type; - new->method = HTTP_GET; + new->method = HTTP_INVALID; REF_INIT_RETAIN (new, rspamd_http_message_free); -- 2.47.3