]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix HTTP methods other than GET and POST
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 18 Oct 2016 12:46:32 +0000 (13:46 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 18 Oct 2016 12:47:52 +0000 (13:47 +0100)
contrib/http-parser/http_parser.h
src/libutil/http.c

index bac517f51ee78e477328c0142e6373c5829598b8..7929315885f4cfbf93592a4e478948a41bcf8039 100644 (file)
@@ -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)                                           \
index a76ab188e122ff9f5cd4bacada448325700a2602..0df6f190daa82cc2b80061a1b033215b810bd0e5 100644 (file)
@@ -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);