From 977a0aaee4a75a0d9ea67cf7eaadb6b0c5bbf1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 7 Aug 2019 15:35:26 +0200 Subject: [PATCH] Protocols.HTTP: Set the Host header for proxied requests. --- lib/modules/Protocols.pmod/HTTP.pmod/module.pmod | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod index be6b7eea19..e2857f24b7 100644 --- a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod +++ b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod @@ -85,6 +85,11 @@ constant DAV_STORAGE_FULL = 507; // RFC 2518 10.6: Insufficient Storage proxy_headers["Proxy-Authorization"] = "Basic " + MIME.encode_base64((user || "") + ":" + (password || "")); + if (has_value(proxy->host, ":")) { + proxy_headers["host"] = "[" + proxy->host + "]:" + proxy->port; + } else { + proxy_headers["host"] = proxy->host + ":" + proxy->port; + } } if (url->scheme == "http") { @@ -463,6 +468,11 @@ void do_async_proxied_method(string|Standards.URI proxy, proxy_headers["Proxy-Authorization"] = "Basic " + MIME.encode_base64((user || "") + ":" + (password || "")); + if (has_value(proxy->host, ":")) { + proxy_headers["host"] = "[" + proxy->host + "]:" + proxy->port; + } else { + proxy_headers["host"] = proxy->host + ":" + proxy->port; + } } if (url->scheme == "http") { -- GitLab