1810
1810
if (defined $sd) {
1811
## send the request to the http server
1812
verbose("CONNECTED: ", $use_ssl ? 'using SSL' : 'using HTTP');
1813
verbose("SENDING:", $request);
1811
## send the request to the http server
1812
verbose("CONNECTED: ", $use_ssl ? 'using SSL' : 'using HTTP');
1813
verbose("SENDING:", $request);
1815
1815
$0 = sprintf("%s - sending to %s port %s", $program, $peer, $port);
1816
my $result = syswrite $sd, $rq;
1817
if ($result != length($rq)) {
1818
warning("cannot send to $peer:$port ($!).");
1822
local $SIG{'ALRM'} = sub { $timeout = 1; };
1816
my $result = syswrite $sd, $rq;
1817
if ($result != length($rq)) {
1818
warning("cannot send to $peer:$port ($!).");
1820
$0 = sprintf("%s - reading from %s port %s", $program, $peer, $port);
1822
local $SIG{'ALRM'} = sub { die "timeout";};
1823
alarm(opt('timeout')) if opt('timeout') > 0;
1824
while ($_ = <$sd>) {
1825
$0 = sprintf("%s - read from %s port %s", $program, $peer, $port);
1826
verbose("RECEIVE:", "%s", define($_, "<undefined>"));
1827
$reply .= $_ if defined $_;
1829
if (opt('timeout') > 0) {
1824
$0 = sprintf("%s - reading from %s port %s", $program, $peer, $port);
1825
alarm(opt('timeout')) if opt('timeout') > 0;
1826
while (!$timeout && ($_ = <$sd>)) {
1827
$0 = sprintf("%s - read from %s port %s", $program, $peer, $port);
1828
verbose("RECEIVE:", "%s", define($_, "<undefined>"));
1829
$reply .= $_ if defined $_;
1831
if (opt('timeout') > 0) {
1836
warning("TIMEOUT: %s after %s seconds", $to, opt('timeout'));
1839
$reply = '' if !defined $reply;
1835
if ($@ and $@ =~ /timeout/) {
1836
warning("TIMEOUT: %s after %s seconds", $to, opt('timeout'));
1839
$reply = '' if !defined $reply;
1842
1842
$0 = sprintf("%s - closed %s port %s", $program, $peer, $port);