Commit 2d93c4a
Accept PeerAddr of 0.
This turned up while messing with a little Dancer2 app. The startup
notification said 'Accepting connections at http://0:5000/', and the
curl program is fine with that. But LWP::UserAgent was not, complaining
that 'No Host option provided'.
I tracked this to Net::HTTP::Methods, specifically its http_configure()
method, which was called with $cnf = { ..., PeerAddr => 0, ... }. It
computes
my $peer = $cnf->{PeerAddr} || $cnf->{PeerHost};
and dies with the given message if $peer is false.
The patch iterates over PeerAddr and PeerHost and sets $peer to the
first found which is defined and not the empty string. I have installed
this on my system, and LWP::UserAgent is now happy with
'http://0:5000/'.
Now, I do not claim to know if a host of '0' is official in any way, but
the fact that Dancer2 requests it and curl accepts it looks to me like a
pragmatic reason to handle it.
I was unable to get Perl 5.6.2 configured for testing, but the modified
code does pass under 5.8.4, at least on my box. For what it is worth,
perlver says the syntax is good back to 5.6.0.1 parent fdc8787 commit 2d93c4a
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
0 commit comments