From 6e95f83a94eac93a4cb5596430e2c03a24536a50 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 18 Mar 2019 16:00:36 +0000 Subject: [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) { -- cgit v1.2.3