Issue 24209: Allow IPv6 bind in http.server (original) (raw)

Created on 2015-05-16 13:54 by Link Mauve, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ipv6.patch Link Mauve,2015-05-16 13:54 Patch adding IPv6 support to http.server. review
Pull Requests
URL Status Linked Edit
PR 10595 merged lisroach,2018-11-19 02:52
PR 11767 merged jaraco,2019-02-06 01:33
PR 11767 merged jaraco,2019-02-06 01:33
PR 11767 merged jaraco,2019-02-06 01:33
Messages (6)
msg243317 - (view) Author: (Link Mauve) Date: 2015-05-16 13:54
When running `python -m http.server -b ::` (or any other IPv6), I’d expect people to be able to download from my IPv6. This patch fixes that issue. I also tested it on a dual-stack kernel, IPv4 requests work just fine and appear as ::ffff:127.0.0.1 for example.
msg243883 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-05-23 03:53
I am no IPv6 expert, but this looks like a reasonable first approximation. The “http.server” module documentation should also be updated to say IPv6 addresses are supported on the command line, and I guess there should be a test case added. But maybe see Lib/smtpd.py line 657 for how this is done in a more general way for the SMTP server module (Issue 14758), using getaddrinfo(). There is also Issue 20215 proposing to do something equivalent in the lower level “socketserver” module, which would probably make this change redundant. It would also be nice for it to bind to both IPv4 and IPv6 if possible, but that is apparently not easy to do cross platform; see Issue 3213.
msg315853 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2018-04-27 18:35
From what I can tell, there's not currently any tests for the behavior of `http.server` as a script, and that sounds like a non-trivial behavior to test. I agree documentation updates for this change are essential, but I'd suggest a test is too high a burden to ask for a change like this when there aren't already tests exercising the related functionality.
msg330071 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2018-11-19 02:54
Looks like the original author isn't around anymore (feel free to chime in if you are, Link!), so I went ahead and made a PR. I added a quick unit test, it's not much but more than nothing, plus updated the documentation.
msg334897 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-02-06 00:53
I don't believe the current patch as accepted has the right behaviors. First off, the default behavior, which indicates "all interfaces" only binds to IPv4 interfaces. Additionally, "-b localhost" only binds to IPv4 localhost. Ideally, the bind should happen on all stacks unless a specific stack is indicated.
msg335020 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2019-02-07 13:22
New changeset f289084c83190cc72db4a70c58f007ec62e75247 by Jason R. Coombs in branch 'master': bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. (#11767) https://github.com/python/cpython/commit/f289084c83190cc72db4a70c58f007ec62e75247
History
Date User Action Args
2022-04-11 14:58:16 admin set github: 68397
2019-02-07 13:28:36 jaraco set status: open -> closedresolution: fixedstage: patch review -> resolved
2019-02-07 13:22:49 jaraco set messages: +
2019-02-06 01:33:41 jaraco set stage: resolved -> patch reviewpull_requests: + <pull%5Frequest11728>
2019-02-06 01:33:26 jaraco set stage: resolved -> resolvedpull_requests: + <pull%5Frequest11727>
2019-02-06 01:33:11 jaraco set stage: resolved -> resolvedpull_requests: + <pull%5Frequest11726>
2019-02-06 00:53:43 jaraco set assignee: jaracomessages: +
2018-11-26 18:44:45 lisroach set stage: patch review -> resolved
2018-11-19 03:45:00 gregory.p.smith set versions: + Python 3.8, - Python 3.6
2018-11-19 02:54:20 lisroach set nosy: + lisroachmessages: +
2018-11-19 02:52:35 lisroach set stage: test needed -> patch reviewpull_requests: + <pull%5Frequest9840>
2018-10-23 21:06:22 masthana set nosy: + masthana
2018-10-10 15:32:39 rpodgorny set nosy: + rpodgorny
2018-04-27 18:35:04 jaraco set messages: +
2018-04-27 18:15:46 jaraco set nosy: + jaraco
2017-01-25 22:21:26 gregory.p.smith set nosy: + gregory.p.smith
2016-04-04 23:03:09 jleedev set nosy: + jleedev
2015-05-23 19:01:22 berker.peksag set nosy: + berker.peksagversions: - Python 3.5
2015-05-23 03:53:05 martin.panter set stage: test neededmessages: + versions: - Python 3.4
2015-05-22 16:40:05 demian.brecht set nosy: + demian.brecht
2015-05-16 22:51:57 martin.panter set nosy: + martin.panter
2015-05-16 13:54:45 Link Mauve create