Skip to content

Commit e9142a9

Browse files
ppisargenio
authored andcommitted
Handle undef and empty LocalAddr
IO::Socket::INET interprets undefined and empty string LocalAddr arguments as an unspecified address while IO::Socket::IP returns an error. This seems to be one of the differences between the two Socket implementations. Recent IO::Socket::IP (0.39) accepts undefined value, but still bail outs on an empty string: $ perl -Ilib -MHTTP::Daemon -e '$d=HTTP::Daemon->new(LocalAddr=>undef) or die; print $d->url, qq{\n}' http://fedora-31:42587/ $ perl -Ilib -MHTTP::Daemon -e '$d=HTTP::Daemon->new(LocalAddr=>q{}) or die; print $d->url, qq{\n}' Name or service not known ...propagated at -e line 1. To improve compatibility, this patch adds a special handling for these two values to be accepted as an unspecified value. Though this should be corrected on IO::Socket:IP side probably. CPAN RT#91699 CPAN RT#123069 Signed-off-by: Petr Písař <ppisar@redhat.com>
1 parent 7ab7ebd commit e9142a9

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for HTTP-Daemon
22

33
{{$NEXT}}
4+
- Handle undef and empty LocalAddr value in new() constructor as an
5+
unspecified address (GH#24, RT#123069)
46

57
6.05 2019-07-26 20:41:05Z
68
- Added the .perltidyrc from the libwww-perl distribution

lib/HTTP/Daemon.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ sub new {
2222
my ($class, %args) = @_;
2323
$args{Listen} ||= 5;
2424
$args{Proto} ||= 'tcp';
25+
26+
# Handle undefined or empty local address the same way as
27+
# IO::Socket::INET -- use unspecified address
28+
for my $key (qw(LocalAddr LocalHost)) {
29+
if (exists $args{$key} && (!defined $args{$key} || $args{$key} eq '')) {
30+
delete $args{$key};
31+
}
32+
}
2533
return $class->SUPER::new(%args);
2634
}
2735

0 commit comments

Comments
 (0)