Changed 'establish_http_connection' to support connecting to an upstream proxy with a 'basic_auth' field

This commit is contained in:
Valen Blanco 2016-10-04 18:25:55 +02:00
parent 9fac3ef792
commit 474e3f35a1

View File

@ -267,6 +267,17 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request)
"Connection: close\r\n", "Connection: close\r\n",
request->method, request->path, request->method, request->path,
request->host, portbuff); 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 { } else {
return write_message (connptr->server_fd, return write_message (connptr->server_fd,
"%s %s HTTP/1.0\r\n" "%s %s HTTP/1.0\r\n"