From 474e3f35a115f53fa0fa46dba5d9d93db4553cdb Mon Sep 17 00:00:00 2001 From: Valen Blanco Date: Tue, 4 Oct 2016 18:25:55 +0200 Subject: [PATCH] Changed 'establish_http_connection' to support connecting to an upstream proxy with a 'basic_auth' field --- src/reqs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/reqs.c b/src/reqs.c index 990152a..26158ae 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -267,6 +267,17 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request) "Connection: close\r\n", request->method, request->path, request->host, portbuff); + } else if ((connptr->upstream_proxy) && + (connptr->upstream_proxy->basic_auth)) { + /* Basic auth is set for upstream proxy. */ + return write_message (connptr->server_fd, + "%s %s HTTP/1.0\r\n" + "Host: %s%s\r\n" + "Connection: close\r\n" + "Proxy-Authorization: Basic %s\r\n", + request->method, request->path, + request->host, portbuff, + connptr->upstream_proxy->basic_auth); } else { return write_message (connptr->server_fd, "%s %s HTTP/1.0\r\n"