mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
removed dependencies for LWP::UserAgent and HTTP::Request;
replaced with GetHttpFile from 99_updatefhem.pm git-svn-id: https://svn.fhem.de/fhem/trunk@1287 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
516e737519
commit
baba0cc0a6
@ -37,7 +37,7 @@
|
|||||||
# Changes:
|
# Changes:
|
||||||
#---------
|
#---------
|
||||||
# 2012-02-03 0.1 initial realease
|
# 2012-02-03 0.1 initial realease
|
||||||
#
|
# 2012-02-25 0.2 removed dependencies for LWP::UserAgent and HTTP::Request;
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
package main;
|
package main;
|
||||||
@ -45,8 +45,7 @@ package main;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use LWP::UserAgent;
|
use IO::Socket;
|
||||||
use HTTP::Request;
|
|
||||||
|
|
||||||
use constant PARAM_NAME => 1;
|
use constant PARAM_NAME => 1;
|
||||||
use constant PARAM_HOST => 2;
|
use constant PARAM_HOST => 2;
|
||||||
@ -121,46 +120,29 @@ NetIO230B_Request($@)
|
|||||||
my $URL='';
|
my $URL='';
|
||||||
my $log='';
|
my $log='';
|
||||||
|
|
||||||
$URL="http://".$hash->{HOST}."/tgi/control.tgi?l=p:". $hash->{USER}.":".$hash->{PASS}."&p=";
|
my $response = GetHttpFile($hash->{HOST}.":80","/tgi/control.tgi?l=p:". $hash->{USER}.":".$hash->{PASS}."&p=l");
|
||||||
if($cmd eq "set") {
|
if(!$response or length($response)==0)
|
||||||
$URL .= "$list";
|
|
||||||
} else {
|
|
||||||
$URL .= "l";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $agent = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1, timeout => 30);
|
|
||||||
my $header = HTTP::Request->new(GET => $URL);
|
|
||||||
my $request = HTTP::Request->new('GET', $URL, $header);
|
|
||||||
my $response = $agent->request($request);
|
|
||||||
|
|
||||||
$log.= "Can't get $URL -- ".$response->status_line
|
|
||||||
unless $response->is_success;
|
|
||||||
|
|
||||||
if($log ne "")
|
|
||||||
{
|
{
|
||||||
Log 3, "NetIO230B_Request: ".$log;
|
Log 3, "NetIO230B_Request failed: ".$log;
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
|
|
||||||
# read decoded content
|
|
||||||
my $buffer = $response->decoded_content;
|
|
||||||
|
|
||||||
# strip html tags
|
# strip html tags
|
||||||
$buffer =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
|
$response =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
|
||||||
|
|
||||||
# strip leading whitespace
|
# strip leading whitespace
|
||||||
$buffer =~ s/^\s+//;
|
$response =~ s/^\s+//;
|
||||||
|
|
||||||
#strip trailing whitespace
|
#strip trailing whitespace
|
||||||
$buffer =~ s/\s+$//;
|
$response =~ s/\s+$//;
|
||||||
|
|
||||||
return $buffer if ($cmd eq "set");
|
return $response if ($cmd eq "set");
|
||||||
|
|
||||||
#+++todo
|
#+++todo
|
||||||
#555 FORBIDDEN
|
#555 FORBIDDEN
|
||||||
|
|
||||||
#split the result into an array
|
#split the result into an array
|
||||||
my @values=split(/ */,$buffer);
|
my @values=split(/ */,$response);
|
||||||
|
|
||||||
#save the values to the readings hash
|
#save the values to the readings hash
|
||||||
my $state = "???";
|
my $state = "???";
|
||||||
@ -183,7 +165,7 @@ NetIO230B_Request($@)
|
|||||||
# Log 1, "$r S: $k{$r}{VAL} T: $k{$r}{TIME}";
|
# Log 1, "$r S: $k{$r}{VAL} T: $k{$r}{TIME}";
|
||||||
#}
|
#}
|
||||||
|
|
||||||
return $buffer;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
### _Define routing is called when fhem starts -> 'reloading' of the module does not call the define routine!!
|
### _Define routing is called when fhem starts -> 'reloading' of the module does not call the define routine!!
|
||||||
|
Loading…
Reference in New Issue
Block a user