From 7cb333171025489e29dcfd830fd76e00f90a5163 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 9 Sep 2017 10:20:16 +0000 Subject: [PATCH] HttpUtils: add proxyAuth (Forum #60471) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@15033 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/HttpUtils.pm | 11 +++++++++-- docs/commandref_frame.html | 4 ++++ docs/commandref_frame_DE.html | 4 ++++ fhem.pl | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/FHEM/HttpUtils.pm b/FHEM/HttpUtils.pm index e92a6cb63..8744fd51f 100644 --- a/FHEM/HttpUtils.pm +++ b/FHEM/HttpUtils.pm @@ -392,6 +392,7 @@ sub HttpUtils_Connect2($) { my ($hash) = @_; + my $usingSSL; $hash->{host} =~ s/:.*//; if($hash->{protocol} eq "https" && $hash->{conn} && !$hash->{hu_sslAdded}) { @@ -403,11 +404,13 @@ HttpUtils_Connect2($) return $errstr; } else { $hash->{conn}->blocking(1); + $usingSSL = 1; if($hash->{hu_proxy}) { # can block! + my $pw = AttrVal("global", "proxyAuth", ""); + $pw = "Proxy-Authorization: Basic $pw\r\n" if($pw); my $hdr = "CONNECT $hash->{host}:$hash->{hu_port} HTTP/1.0\r\n". - "User-Agent: fhem\r\n". - "\r\n"; + "User-Agent: fhem\r\n$pw\r\n"; syswrite $hash->{conn}, $hdr; my $buf; my $len = sysread($hash->{conn},$buf,65536); @@ -504,6 +507,10 @@ HttpUtils_Connect2($) $hdr .= "Content-Type: application/x-www-form-urlencoded\r\n" if ($hdr !~ "Content-Type:"); } + if(!$usingSSL) { + my $pw = AttrVal("global", "proxyAuth", ""); + $hdr .= "Proxy-Authorization: Basic $pw\r\n" if($pw); + } Log3 $hash, $hash->{loglevel}+1, "HttpUtils request header:\n$hdr"; $hdr .= "\r\n"; diff --git a/docs/commandref_frame.html b/docs/commandref_frame.html index 6888a79f8..228f338da 100644 --- a/docs/commandref_frame.html +++ b/docs/commandref_frame.html @@ -1519,6 +1519,10 @@ The following local attributes are used by a wider range of devices: