Closed skaji closed 4 years ago
So far so good. I applied your patch to existing HTTP-Daemon-6.07 and called the result 6.07_001. I added one more debugging line to your first test program so as to print the perl
version. Results on 3 BSDs:
FreeBSD
$ uname -mrs
FreeBSD 11.2-STABLE amd64
$ perl -I/usr/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-daemon-gh38-test.pl
Perl version: v5.28.2
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.18
HTTP GET http://[::1]:64633/
200 OK
$ bleadperl -I/usr/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-daemon-gh38-test.pl
Perl version: v5.31.12
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.22
HTTP GET http://[::1]:10182/
200 OK
OpenBSD
$ uname -mrs
OpenBSD 6.6 amd64
$ perl -I/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-daemon->
Perl version: v5.28.2
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.13
HTTP GET http://127.0.0.1:22871/
200 OK
$ bleadperl -I/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-da>
Perl version: v5.31.12
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.22
HTTP GET http://127.0.0.1:6970/
200 OK
NetBSD
$ uname -mrs
NetBSD 8.0 amd64
$ perl -I/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-daemon-gh38-test.pl
Perl version: v5.30.2
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.18
HTTP GET http://[::1]:65393/
200 OK
$ bleadperl -I/home/jkeenan/learn/perl/HTTP-Daemon-6.07-patched/lib skaji-http-daemon-gh38-test.pl
Perl version: v5.32.0
HTTP::Daemon version: 6.07_001
HTTP::Response version: 6.24
HTTP GET http://[::1]:65391/
200 OK
I have not yet had an opportunity to run the Test-Smoke test suite with this patch but will try to do so in the coming days. Please let me know what other testing procedures you might need.
Thank you very much. Jim Keenan
So far so good. I applied your patch to existing HTTP-Daemon-6.07 and called the result 6.07_001. I added one more debugging line to your first test program so as to print the
perl
version. Results on 3 BSDs:
[snip]
I have not yet had an opportunity to run the Test-Smoke test suite with this patch but will try to do so in the coming days. Please let me know what other testing procedures you might need.
I have now run the Test-Smoke test suite with your patched HTTP::Daemon. Please see: https://rt.cpan.org/Ticket/Display.html?id=132642#txn-1898592
These results suggest that while LWP::UserAgent and HTTP::Tiny "play well" with the patched version of HTTP::Daemon, HTTP::Lite has problems.
Thank you very much. Jim Keenan
Thanks everyone!
This PR will fix #38, that is "Sometimes cannot be accessed via $d->url".
When we are not able to access servers via $d->url
Let's say we create an HTTP::Daemon server by
Then,
$d->sockaddr
is INADDR_ANY (0.0.0.0) or IN6ADDR_ANY (::1), so$d->url
returnshttp://hostname:XXX/
, wherehostname
is the hostname of the local machine returned bySys::Hostname::hostname
, andXXX
is some port number.Then, there are 2 cases that we are not able to access the server via
$d->url
:hostname
is not resolvable to IP addresses.hostname
is resolved to IPv4, but $d restricts connections to IPv6 only.How to fix it
$d->sockhost
is '0.0.0.0', then use '127.0.0.1' for host in$d->url
$d->sockhost
is '::', then use '::1' for host in$d->url
$d->sockhost
), not hostname or domain.Backward compatibility
Although this PR will fix #38, we should note that this PR may break some use cases.
As I mentioned above, currently, when we create HTTP::Daemon by
my $d = HTTP::Daemon->new
,$d->url
becomeshttp://hostname:XXX
. But after this PR,$d->url
will becomehttp://127.0.0.1:XXX
orhttp://[::1]:XXX
.Apparently, the ip addresses
127.0.0.1
and::1
are reasonable only in the local machine. On the other hand, thehostname
may be reasonable not only in local machine, but also in remote machines.So this PR may cause an issue "we are not able to access servers from remote machines via
$d->url
".