diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-07 15:58:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-07 15:58:25 +0100 |
commit | c9b63f6a3d73d4ef8895391ff196dbc680895735 (patch) | |
tree | 3f8dc86be4a27eccb5bf494b85518f6f8b4ff90b /src/libutil/http.c | |
parent | b94bca12346963f3aa66d03bd4c61b09555c6878 (diff) | |
download | rspamd-c9b63f6a3d73d4ef8895391ff196dbc680895735.tar.gz rspamd-c9b63f6a3d73d4ef8895391ff196dbc680895735.zip |
[Minor] Do not set implicit content-type in HTTP
Diffstat (limited to 'src/libutil/http.c')
-rw-r--r-- | src/libutil/http.c | 97 |
1 files changed, 68 insertions, 29 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 0edd74d1a..1a226773a 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1776,16 +1776,31 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, if (encrypted) { /* Internal reply (encrypted) */ - meth_len = - rspamd_snprintf (repbuf, replen, - "HTTP/1.1 %d %T\r\n" - "Connection: close\r\n" - "Server: %s\r\n" - "Date: %s\r\n" - "Content-Length: %z\r\n" - "Content-Type: %s", /* NO \r\n at the end ! */ - msg->code, &status, "rspamd/" RVERSION, datebuf, - bodylen, mime_type); + if (mime_type) { + meth_len = + rspamd_snprintf (repbuf, replen, + "HTTP/1.1 %d %T\r\n" + "Connection: close\r\n" + "Server: %s\r\n" + "Date: %s\r\n" + "Content-Length: %z\r\n" + "Content-Type: %s", /* NO \r\n at the end ! */ + msg->code, &status, "rspamd/" RVERSION, + datebuf, + bodylen, mime_type); + } + else { + meth_len = + rspamd_snprintf (repbuf, replen, + "HTTP/1.1 %d %T\r\n" + "Connection: close\r\n" + "Server: %s\r\n" + "Date: %s\r\n" + "Content-Length: %z", /* NO \r\n at the end ! */ + msg->code, &status, "rspamd/" RVERSION, + datebuf, + bodylen); + } enclen += meth_len; /* External reply */ rspamd_printf_fstring (buf, @@ -1798,16 +1813,31 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, datebuf, enclen); } else { - meth_len = - rspamd_printf_fstring (buf, - "HTTP/1.1 %d %T\r\n" - "Connection: close\r\n" - "Server: %s\r\n" - "Date: %s\r\n" - "Content-Length: %z\r\n" - "Content-Type: %s\r\n", - msg->code, &status, "rspamd/" RVERSION, datebuf, - bodylen, mime_type); + if (mime_type) { + meth_len = + rspamd_printf_fstring (buf, + "HTTP/1.1 %d %T\r\n" + "Connection: close\r\n" + "Server: %s\r\n" + "Date: %s\r\n" + "Content-Length: %z\r\n" + "Content-Type: %s\r\n", + msg->code, &status, "rspamd/" RVERSION, + datebuf, + bodylen, mime_type); + } + else { + meth_len = + rspamd_printf_fstring (buf, + "HTTP/1.1 %d %T\r\n" + "Connection: close\r\n" + "Server: %s\r\n" + "Date: %s\r\n" + "Content-Length: %z\r\n", + msg->code, &status, "rspamd/" RVERSION, + datebuf, + bodylen); + } } } else { @@ -1894,13 +1924,11 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, } if (bodylen > 0) { - if (mime_type == NULL) { - mime_type = "text/plain"; + if (mime_type != NULL) { + rspamd_printf_fstring (buf, + "Content-Type: %s\r\n", + mime_type); } - - rspamd_printf_fstring (buf, - "Content-Type: %s\r\n", - mime_type); } } } @@ -2057,8 +2085,18 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn priv->outlen = 8; if (bodylen > 0) { - if (mime_type == NULL) { - mime_type = "text/plain"; + if (mime_type != NULL) { + preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n" + "Content-Length: %z\r\n" + "Content-Type: %s\r\n" + "\r\n", ENCRYPTED_VERSION, bodylen, + mime_type); + } + else { + preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n" + "Content-Length: %z\r\n" + "" + "\r\n", ENCRYPTED_VERSION, bodylen); } preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n" @@ -2068,7 +2106,8 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn mime_type); } else { - preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n\r\n", + preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), + "%s\r\n\r\n", ENCRYPTED_VERSION); } |