|
|
bce5a8 |
From b54702ab21edbf1ea0dbc00d978aecc89e5764d6 Mon Sep 17 00:00:00 2001
|
|
|
bce5a8 |
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
|
|
bce5a8 |
Date: Mon, 18 Sep 2017 15:21:16 +0200
|
|
|
bce5a8 |
Subject: [PATCH] Handle undef and empty LocalAddr
|
|
|
bce5a8 |
MIME-Version: 1.0
|
|
|
bce5a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
bce5a8 |
Content-Transfer-Encoding: 8bit
|
|
|
bce5a8 |
|
|
|
bce5a8 |
IO::Socket::INET interprets undefined and empty string LocalAddr
|
|
|
bce5a8 |
arguments as an unspecified address while IO::Socket::IP returns an
|
|
|
bce5a8 |
error. This seems to be one of the differences between the two
|
|
|
bce5a8 |
Socket implementations. Recent IO::Socket::IP (0.39) accepts undefined
|
|
|
bce5a8 |
value, but still bail outs on an empty string.
|
|
|
bce5a8 |
|
|
|
bce5a8 |
To improve compatibility, this patch adds a special handling for these
|
|
|
bce5a8 |
two values to be accepted as an unspecified value. Though this should
|
|
|
bce5a8 |
be corrected on IO::Socket:IP side probably.
|
|
|
bce5a8 |
|
|
|
bce5a8 |
CPAN RT#91699
|
|
|
bce5a8 |
CPAN RT#123069
|
|
|
bce5a8 |
|
|
|
bce5a8 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
bce5a8 |
---
|
|
|
bce5a8 |
lib/HTTP/Daemon.pm | 8 ++++++++
|
|
|
bce5a8 |
1 file changed, 8 insertions(+)
|
|
|
bce5a8 |
|
|
|
bce5a8 |
diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm
|
|
|
bce5a8 |
index 0e22b77..1e9d48e 100644
|
|
|
bce5a8 |
--- a/lib/HTTP/Daemon.pm
|
|
|
bce5a8 |
+++ b/lib/HTTP/Daemon.pm
|
|
|
bce5a8 |
@@ -18,6 +18,14 @@ sub new
|
|
|
bce5a8 |
my($class, %args) = @_;
|
|
|
bce5a8 |
$args{Listen} ||= 5;
|
|
|
bce5a8 |
$args{Proto} ||= 'tcp';
|
|
|
bce5a8 |
+ # Handle undefined or empty local address the same way as
|
|
|
bce5a8 |
+ # IO::Socket::INET -- use unspecified address
|
|
|
bce5a8 |
+ for my $key (qw(LocalAddr LocalHost)) {
|
|
|
bce5a8 |
+ if (exists $args{$key} &&
|
|
|
bce5a8 |
+ (!defined($args{$key}) || $args{$key} eq '')) {
|
|
|
bce5a8 |
+ delete $args{$key};
|
|
|
bce5a8 |
+ }
|
|
|
bce5a8 |
+ }
|
|
|
bce5a8 |
return $class->SUPER::new(%args);
|
|
|
bce5a8 |
}
|
|
|
bce5a8 |
|
|
|
bce5a8 |
--
|
|
|
bce5a8 |
2.13.5
|
|
|
bce5a8 |
|