New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow IPv6 bind in http.server #68397
Comments
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. |
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 (bpo-14758), using getaddrinfo(). There is also bpo-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 bpo-3213. |
From what I can tell, there's not currently any tests for the behavior of |
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. |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: