From d97f53a95530cb73f847a366210a29f5e1b58f61 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Jul 2016 14:13:53 +0100 Subject: [PATCH] [Fix] Another fix for legacy clients --- src/libutil/http.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/libutil/http.c b/src/libutil/http.c index 93e946ffc..f2d1675c4 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1675,7 +1675,10 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, else { /* Legacy spamd reply */ if (msg->flags & RSPAMD_HTTP_FLAG_SPAMC) { - rspamd_printf_fstring (buf, "SPAMD/1.1 0 EX_OK\r\n"); + rspamd_printf_fstring (buf, "SPAMD/1.1 0 EX_OK\r\n" + "Content-length: %z\r\n" + "\r\n", + bodylen); } else { rspamd_printf_fstring (buf, "RSPAMD/1.3 0 EX_OK\r\n"); @@ -1929,14 +1932,17 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn peer_key = msg->peer_key; priv->wr_total = bodylen + 2; + hdrcount = 0; - HASH_ITER (hh, msg->headers, hdr, htmp) { - /* */ - priv->wr_total += hdr->combined->len; - enclen += hdr->combined->len; - priv->outlen ++; - hdrcount ++; + if (msg->method < HTTP_SYMBOLS) { + HASH_ITER (hh, msg->headers, hdr, htmp) { + /* */ + priv->wr_total += hdr->combined->len; + enclen += hdr->combined->len; + priv->outlen ++; + hdrcount ++; + } } /* Allocate iov */ @@ -2005,11 +2011,12 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn } else { i = 1; - HASH_ITER (hh, msg->headers, hdr, htmp) { - priv->out[i].iov_base = hdr->combined->str; - priv->out[i++].iov_len = hdr->combined->len; - } if (msg->method < HTTP_SYMBOLS) { + HASH_ITER (hh, msg->headers, hdr, htmp) { + priv->out[i].iov_base = hdr->combined->str; + priv->out[i++].iov_len = hdr->combined->len; + } + priv->out[i].iov_base = "\r\n"; priv->out[i++].iov_len = 2; } -- 2.39.5