commit 6e95f83: [Project] Add support of HTTP proxy in requests

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Mar 18 16:21:09 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-18 16:00:36 +0000
URL: https://github.com/rspamd/rspamd/commit/6e95f83a94eac93a4cb5596430e2c03a24536a50

[Project] Add support of HTTP proxy in requests
Issue: #572

---
 src/libutil/http_connection.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/libutil/http_connection.c b/src/libutil/http_connection.c
index 78ec2582f..ea664f20d 100644
--- a/src/libutil/http_connection.c
+++ b/src/libutil/http_connection.c
@@ -1862,6 +1862,7 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
 			}
 
 			if (encrypted) {
+				/* TODO: Add proxy support to HTTPCrypt */
 				rspamd_printf_fstring (buf,
 						"%s %s HTTP/1.1\r\n"
 						"Connection: %s\r\n"
@@ -1875,16 +1876,32 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
 						enclen);
 			}
 			else {
-				rspamd_printf_fstring (buf,
-						"%s %V HTTP/1.1\r\n"
-						"Connection: %s\r\n"
-						"Host: %s\r\n"
-						"Content-Length: %z\r\n",
-						http_method_str (msg->method),
-						msg->url,
-						conn_type,
-						host,
-						bodylen);
+				if (conn->priv->flags & RSPAMD_HTTP_CONN_FLAG_PROXY) {
+					rspamd_printf_fstring (buf,
+							"%s http://%s:%d/%V HTTP/1.1\r\n"
+							"Connection: %s\r\n"
+							"Host: %s\r\n"
+							"Content-Length: %z\r\n",
+							http_method_str (msg->method),
+							host,
+							msg->port,
+							msg->url,
+							conn_type,
+							host,
+							bodylen);
+				}
+				else {
+					rspamd_printf_fstring (buf,
+							"%s %V HTTP/1.1\r\n"
+							"Connection: %s\r\n"
+							"Host: %s\r\n"
+							"Content-Length: %z\r\n",
+							http_method_str (msg->method),
+							msg->url,
+							conn_type,
+							host,
+							bodylen);
+				}
 
 				if (bodylen > 0) {
 					if (mime_type != NULL) {


More information about the Commits mailing list