summaryrefslogtreecommitdiff
path: root/p5-http-daemon/HTTP-Daemon-6.01-Handle-undef-and-empty-LocalAddr.patch
blob: f6fe28976f3e9d82db9c58c015c639aa69c51af8 (plain)
    1 From b54702ab21edbf1ea0dbc00d978aecc89e5764d6 Mon Sep 17 00:00:00 2001
    2 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
    3 Date: Mon, 18 Sep 2017 15:21:16 +0200
    4 Subject: [PATCH] Handle undef and empty LocalAddr
    5 MIME-Version: 1.0
    6 Content-Type: text/plain; charset=UTF-8
    7 Content-Transfer-Encoding: 8bit
    8 
    9 IO::Socket::INET interprets undefined and empty string LocalAddr
   10 arguments as an unspecified address while IO::Socket::IP returns an
   11 error. This seems to be one of the differences between the two
   12 Socket implementations. Recent IO::Socket::IP (0.39) accepts undefined
   13 value, but still bail outs on an empty string.
   14 
   15 To improve compatibility, this patch adds a special handling for these
   16 two values to be accepted as an unspecified value. Though this should
   17 be corrected on IO::Socket:IP side probably.
   18 
   19 CPAN RT#91699
   20 CPAN RT#123069
   21 
   22 Signed-off-by: Petr Písař <ppisar@redhat.com>
   23 ---
   24  lib/HTTP/Daemon.pm | 8 ++++++++
   25  1 file changed, 8 insertions(+)
   26 
   27 diff --git a/lib/HTTP/Daemon.pm b/lib/HTTP/Daemon.pm
   28 index 0e22b77..1e9d48e 100644
   29 --- a/lib/HTTP/Daemon.pm
   30 +++ b/lib/HTTP/Daemon.pm
   31 @@ -18,6 +18,14 @@ sub new
   32      my($class, %args) = @_;
   33      $args{Listen} ||= 5;
   34      $args{Proto}  ||= 'tcp';
   35 +    # Handle undefined or empty local address the same way as
   36 +    # IO::Socket::INET -- use unspecified address
   37 +    for my $key (qw(LocalAddr LocalHost)) {
   38 +        if (exists $args{$key} &&
   39 +            (!defined($args{$key}) || $args{$key} eq '')) {
   40 +            delete $args{$key};
   41 +        }
   42 +    }
   43      return $class->SUPER::new(%args);
   44  }
   45  
   46 -- 
   47 2.13.5

Generated by cgit