classification
Title: Allow IPv6 bind in http.server
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Link Mauve, berker.peksag, demian.brecht, gregory.p.smith, jason.coombs, jleedev, martin.panter, rpodgorny
Priority: normal Keywords: patch

Created on 2015-05-16 13:54 by Link Mauve, last changed 2018-10-10 15:32 by rpodgorny.

Files
File name Uploaded Description Edit
ipv6.patch Link Mauve, 2015-05-16 13:54 Patch adding IPv6 support to http.server. review
Messages (3)
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 (jason.coombs) * (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.
History
Date User Action Args
2018-10-10 15:32:39rpodgornysetnosy: + rpodgorny
2018-04-27 18:35:04jason.coombssetmessages: + msg315853
2018-04-27 18:15:46jason.coombssetnosy: + jason.coombs
2017-01-25 22:21:26gregory.p.smithsetnosy: + gregory.p.smith
2016-04-04 23:03:09jleedevsetnosy: + jleedev
2015-05-23 19:01:22berker.peksagsetnosy: + berker.peksag

versions: - Python 3.5
2015-05-23 03:53:05martin.pantersetstage: test needed
messages: + msg243883
versions: - Python 3.4
2015-05-22 16:40:05demian.brechtsetnosy: + demian.brecht
2015-05-16 22:51:57martin.pantersetnosy: + martin.panter
2015-05-16 13:54:45Link Mauvecreate