From 8e2bcb60a3225d9136f8143be923cf6fb3d29711 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 5 Feb 2017 15:24:52 +0100 Subject: [Minor] Deal with HTTP requests without content length --- src/libutil/http.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libutil/http.c b/src/libutil/http.c index 47c1836d3..649cebeb2 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1197,17 +1197,21 @@ rspamd_http_event_handler (int fd, short what, gpointer ud) } } else if (r == 0) { - if (!conn->finished) { - err = g_error_new (HTTP_ERROR, - errno, - "IO read error: unexpected EOF"); - conn->error_handler (conn, err); - g_error_free (err); - } - REF_RELEASE (pbuf); - rspamd_http_connection_unref (conn); + /* We can still call http parser */ + if (http_parser_execute (&priv->parser, &priv->parser_cb, d, r) + != (size_t)r) { + if (!conn->finished) { + err = g_error_new (HTTP_ERROR, + errno, + "IO read error: unexpected EOF"); + conn->error_handler (conn, err); + g_error_free (err); + } + REF_RELEASE (pbuf); + rspamd_http_connection_unref (conn); - return; + return; + } } else { if (!priv->ssl) { -- cgit v1.2.3