From 2bc56af20d0b7b645bcc96c6b1a70149e889e7fd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 11 Mar 2015 14:28:34 +0000 Subject: [PATCH] Distinguish spamc/rspamc in http code. Conflicts: src/libutil/http.c --- src/libutil/http.c | 11 ++++++++++- src/libutil/http.h | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libutil/http.c b/src/libutil/http.c index 5a597fbd21..02740081a0 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -503,6 +503,10 @@ rspamd_http_on_headers_complete (http_parser * parser) priv->msg->body = g_string_sized_new (BUFSIZ); } + if (parser->flags & F_SPAMC) { + priv->msg->flags |= RSPAMD_HTTP_FLAG_SPAMC; + } + priv->msg->method = parser->method; priv->msg->code = parser->status_code; @@ -965,7 +969,12 @@ rspamd_http_connection_write_message (struct rspamd_http_connection *conn, } else { /* Legacy spamd reply */ - rspamd_printf_gstring (buf, "RSPAMD/1.3 0 EX_OK\r\n"); + if (msg->flags & RSPAMD_HTTP_FLAG_SPAMC) { + rspamd_printf_gstring (buf, "SPAMD/1.1 0 EX_OK\r\n"); + } + else { + rspamd_printf_gstring (buf, "RSPAMD/1.3 0 EX_OK\r\n"); + } } } else { diff --git a/src/libutil/http.h b/src/libutil/http.h index c6fcf0b83f..72c07b4499 100644 --- a/src/libutil/http.h +++ b/src/libutil/http.h @@ -48,6 +48,11 @@ struct rspamd_http_header { struct rspamd_http_header *next, *prev; }; +/** + * Legacy spamc protocol + */ +#define RSPAMD_HTTP_FLAG_SPAMC 1 << 1 + /** * HTTP message structure, used for requests and replies */ @@ -62,6 +67,7 @@ struct rspamd_http_message { time_t date; gint code; enum http_method method; + gint flags; }; -- 2.47.3