2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-08 05:15:10 +00:00

HttpUtils.pm: revert last changes, problems with Huebridge (Forum #120543)

git-svn-id: https://svn.fhem.de/fhem/trunk@24288 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-04-20 16:00:01 +00:00
parent eac04fb94d
commit e8d7397fbf

View File

@ -81,19 +81,17 @@ HttpUtils_Close($)
stacktrace(); stacktrace();
} }
} }
HttpUtils_Cleanup($hash);
delete($hash->{conn}); delete($hash->{conn});
delete($hash->{compress}); # this is a potention user parameter delete($hash->{hu_inProgress});
} delete($hash->{hu_sslAdded});
delete($hash->{hu_filecount});
# Stuff we can delete before we return control from HttpUtils delete($hash->{hu_blocking});
sub delete($hash->{hu_portSfx});
HttpUtils_Cleanup($) delete($hash->{hu_proxy});
{ delete($hash->{hu_port});
my ($hash) = @_;
map { delete($hash->{$_}) if($_ =~ m/^hu_/) } sort keys %{$hash};
delete($hash->{directReadFn}); delete($hash->{directReadFn});
delete($hash->{directWriteFn}); delete($hash->{directWriteFn});
delete($hash->{compress});
} }
sub sub
@ -414,7 +412,7 @@ HttpUtils_Connect($)
IO::Socket::INET6->new(Proto=>'tcp', Blocking=>0); IO::Socket::INET6->new(Proto=>'tcp', Blocking=>0);
if(!$hash->{conn}) { if(!$hash->{conn}) {
Log3 $hash, $hash->{loglevel}, "HttpUtils: Creating socket: $!"; Log3 $hash, $hash->{loglevel}, "HttpUtils: Creating socket: $!";
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
return $hash->{callback}($hash, "Creating socket: $!", ""); return $hash->{callback}($hash, "Creating socket: $!", "");
} }
my $sa = length($iaddr)==4 ? sockaddr_in($port, $iaddr) : my $sa = length($iaddr)==4 ? sockaddr_in($port, $iaddr) :
@ -451,7 +449,7 @@ HttpUtils_Connect($)
my $err = HttpUtils_Connect2($hash); my $err = HttpUtils_Connect2($hash);
if($err) { if($err) {
Log3 $hash, $hash->{loglevel}, "HttpUtils: $err"; Log3 $hash, $hash->{loglevel}, "HttpUtils: $err";
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
$hash->{callback}($hash, $err, ""); $hash->{callback}($hash, $err, "");
} }
return $err; return $err;
@ -558,7 +556,7 @@ HttpUtils_Connect2($)
} }
if($hash->{noConn2}) { if($hash->{noConn2}) {
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
$hash->{callback}($hash); $hash->{callback}($hash);
return undef; return undef;
} }
@ -643,7 +641,7 @@ HttpUtils_Connect2($)
RemoveInternalTimer(\%timerHash); RemoveInternalTimer(\%timerHash);
my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash); my ($err, $ret, $redirect) = HttpUtils_ParseAnswer($hash);
if(!$redirect) { if(!$redirect) {
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
$hash->{callback}($hash, $err, $ret); $hash->{callback}($hash, $err, $ret);
} }
@ -802,8 +800,6 @@ HttpUtils_ParseAnswer($)
if(!$hash->{keepalive}) { if(!$hash->{keepalive}) {
$hash->{conn}->close(); $hash->{conn}->close();
undef $hash->{conn}; undef $hash->{conn};
delete($hash->{FD});
delete($selectlist{$hash});
} }
if(!$hash->{buf} && !$hash->{httpheader}) { if(!$hash->{buf} && !$hash->{httpheader}) {
@ -866,7 +862,7 @@ HttpUtils_ParseAnswer($)
# Request the URL with the Digest response # Request the URL with the Digest response
if($hash->{callback}) { if($hash->{callback}) {
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
HttpUtils_NonblockingGet($hash); HttpUtils_NonblockingGet($hash);
return ("", "", 1); return ("", "", 1);
} else { } else {
@ -891,7 +887,7 @@ HttpUtils_ParseAnswer($)
Log3 $hash, $hash->{loglevel}, "HttpUtils $hash->{displayurl}: ". Log3 $hash, $hash->{loglevel}, "HttpUtils $hash->{displayurl}: ".
"Redirect to ".($hash->{hideurl} ? "<hidden>" : $hash->{url}); "Redirect to ".($hash->{hideurl} ? "<hidden>" : $hash->{url});
if($hash->{callback}) { if($hash->{callback}) {
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
HttpUtils_NonblockingGet($hash); HttpUtils_NonblockingGet($hash);
return ("", "", 1); return ("", "", 1);
} else { } else {
@ -950,7 +946,7 @@ HttpUtils_NonblockingGet($)
my $err = HttpUtils_Connect($hash); my $err = HttpUtils_Connect($hash);
if($err) { if($err) {
HttpUtils_Cleanup($hash); delete($hash->{hu_inProgress});
$hash->{callback}($hash, $err, ""); $hash->{callback}($hash, $err, "");
} }
} }