aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-10 18:02:49 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-10 18:03:35 +0000
commit3205a6a4bd2858c79055a7c83fe63ddd2cdbe457 (patch)
tree2cf126e894f35447875efc3ceaabe59dea33abca /src/libutil
parent98b4d5370a2cd8e26de677151d7f335c4eae7e77 (diff)
downloadrspamd-3205a6a4bd2858c79055a7c83fe63ddd2cdbe457.tar.gz
rspamd-3205a6a4bd2858c79055a7c83fe63ddd2cdbe457.zip
[Fix] Fix Content-Type in HTTP requests
Issue: #1410 Reported by: @cgt
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/http.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c
index 472ca0f5d..df710ac42 100644
--- a/src/libutil/http.c
+++ b/src/libutil/http.c
@@ -1832,13 +1832,26 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
/* Fallback to HTTP/1.0 */
if (encrypted) {
rspamd_printf_fstring (buf,
- "%s %s HTTP/1.0\r\nContent-Length: %z\r\n", "POST",
+ "%s %s HTTP/1.0\r\n"
+ "Content-Length: %z\r\n"
+ "Content-Type: application/octet-stream\r\n",
+ "POST",
"/post", enclen);
}
else {
rspamd_printf_fstring (buf,
- "%s %V HTTP/1.0\r\nContent-Length: %z\r\n",
+ "%s %V HTTP/1.0\r\n"
+ "Content-Length: %z\r\n",
http_method_str (msg->method), msg->url, bodylen);
+ if (bodylen > 0) {
+ if (mime_type == NULL) {
+ mime_type = "text/plain";
+ }
+
+ rspamd_printf_fstring (buf,
+ "Content-Type: %s\r\n",
+ mime_type);
+ }
}
}
else {
@@ -1848,7 +1861,8 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
"%s %s HTTP/1.1\r\n"
"Connection: close\r\n"
"Host: %s\r\n"
- "Content-Length: %z\r\n",
+ "Content-Length: %z\r\n"
+ "Content-Type: application/octet-stream\r\n",
"POST", "/post", host, enclen);
}
else {
@@ -1856,14 +1870,17 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
"%s %s HTTP/1.1\r\n"
"Connection: close\r\n"
"Host: %V\r\n"
- "Content-Length: %z\r\n",
+ "Content-Length: %z\r\n"
+ "Content-Type: application/octet-stream\r\n",
"POST", "/post", msg->host, enclen);
}
}
else {
if (host != NULL) {
rspamd_printf_fstring (buf,
- "%s %V HTTP/1.1\r\nConnection: close\r\nHost: %s\r\nContent-Length: %z\r\n",
+ "%s %V HTTP/1.1\r\nConnection: close\r\n"
+ "Host: %s\r\n"
+ "Content-Length: %z\r\n",
http_method_str (msg->method), msg->url, host,
bodylen);
}
@@ -1876,8 +1893,19 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
http_method_str (msg->method), msg->url, msg->host,
bodylen);
}
+
+ if (bodylen > 0) {
+ if (mime_type == NULL) {
+ mime_type = "text/plain";
+ }
+
+ rspamd_printf_fstring (buf,
+ "Content-Type: %s\r\n",
+ mime_type);
+ }
}
}
+
if (encrypted) {
GString *b32_key, *b32_id;
@@ -2030,8 +2058,15 @@ 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";
+ }
+
preludelen = rspamd_snprintf (repbuf, sizeof (repbuf), "%s\r\n"
- "Content-Length: %z\r\n\r\n", ENCRYPTED_VERSION, bodylen);
+ "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\r\n",