Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134168: http.server with HTTPS fails to bind IPv6 addresses and ignores --directory flag#134169

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
picnixz merged 12 commits intopython:mainfromggqlq:fix_http_cli
May 24, 2025

Conversation

ggqlq
Copy link
Contributor

@ggqlqggqlq commentedMay 18, 2025
edited by bedevere-appbot
Loading

I add a new HTTPSDualStackServer class(like 'DualStackServer') in _main function to handle IPv6 addresses and the--directory flag.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

@ggqlqggqlq changed the titleFix http cligh134168: http.server with HTTPS fails to bind IPv6 addresses and ignores --directory flagMay 18, 2025
@ggqlqggqlq changed the titlegh134168: http.server with HTTPS fails to bind IPv6 addresses and ignores --directory flaggh-134168: http.server with HTTPS fails to bind IPv6 addresses and ignores --directory flagMay 18, 2025
@picnixz

This comment was marked as resolved.

@picnixz
Copy link
Member

And please add tests. I don't understand why--directory is being ignored in the first place.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

ggqlqand others added2 commitsMay 18, 2025 21:44
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…gx3Xg.rstCo-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@ggqlq
Copy link
ContributorAuthor

And please add tests. I don't understand why--directory is being ignored in the first place.

Should we move the runtime tests from PR#132540 to this one?

@picnixz
Copy link
Member

Oh I thought that the other PR was merged. NVM, i'll merge the other one so that you can extend the existing tests.

@picnixz
Copy link
Member

Ok, because we have some failures on the build bots, I've reverted the runtime tests but kept the static tests. Since this fix requires serving real files to check whether it works or not, I'll just assume that it locally works and be happy with it (I mean, what could go wrong?) I'm still planning to fix the runtime tests so that we can have a good coverage but it won't be a priority.

@picnixz
Copy link
Member

I couldn't reproduce the IPv6 issue because I have disabled IPv6 and I'm too lazy to re-enable it. However, I can confirm that this fixes the--directory issue. I can probably confirm though that I don't have the same error (I have an OSError, meaning that the call toself.socket.bind was still ok but my OS didn't want to serve IPv6, while your error was during the parsing of the arguments, so before).

@picnixz
Copy link
Member

@ggqlq Can you manually confirm that IPv6 + SSL works, IPv6 + other directory works, IPv6 + SSL + other directory works. I confirmed with IPv4 o my side.

@ggqlq
Copy link
ContributorAuthor

I think they can all work properly.

IPv6 + SSL

$ ./python -m http.server -b ::1 --tls-cert~/ssl/localhost.crt --tls-key~/ssl/localhost.keyServing HTTPS on ::1 port 8000 (https://[::1]:8000/) ...$ curl -k https://[::1]:8000# ...<ul><li><a href=".azure-pipelines/">.azure-pipelines/</a></li><li><a href=".coveragerc">.coveragerc</a></li># ...

IPv6 + other directory

tree~/test~/test├── 1├── 2└── 31 directory, 3 files$ ./python -m http.server -b ::1 -d~/testServing HTTP on ::1 port 8000 (http://[::1]:8000/) ...$ curl http://[::1]:8000# ...<ul><li><a href="1">1</a></li><li><a href="2">2</a></li><li><a href="3">3</a></li></ul>

IPv6 + SSL + other directory

$ ./python -m http.server -b ::1 -d~/test --tls-cert~/ssl/localhost.crt --tls-key~/ssl/localhost.keyServing HTTPS on ::1 port 8000 (https://[::1]:8000/) ...$ curl -k https://[::1]:8000# ...<ul><li><a href="1">1</a></li><li><a href="2">2</a></li><li><a href="3">3</a></li></ul>

@picnixz
Copy link
Member

Great!

@picnixzpicnixzenabled auto-merge (squash)May 24, 2025 12:14
@picnixzpicnixz added the needs backport to 3.14bugs and security fixes labelMay 24, 2025
@picnixzpicnixzdisabled auto-mergeMay 24, 2025 12:15
@picnixzpicnixzenabled auto-merge (squash)May 24, 2025 12:16
@picnixzpicnixz merged commit2fd09b0 intopython:mainMay 24, 2025
41 checks passed
@miss-islington-app
Copy link

Thanks@ggqlq for the PR, and@picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry,@ggqlq and@picnixz, I could not cleanly backport this to3.14 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 2fd09b011031f3c00c342b44e02e2817010e507c 3.14

@picnixz
Copy link
Member

I'll take care of the bp.

@ggqlq
Copy link
ContributorAuthor

@picnixz Thank you!

picnixz pushed a commit to picnixz/cpython that referenced this pull requestMay 24, 2025
…ory` when serving over HTTPS (python#134169)---------(cherry picked from commit2fd09b0)Co-authored-by: ggqlq <124190229+ggqlq@users.noreply.github.com>
@bedevere-app
Copy link

GH-134630 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 24, 2025
picnixz pushed a commit to picnixz/cpython that referenced this pull requestMay 24, 2025
…-directory` when serving over HTTPS (pythonGH-134169)(cherry picked from commit2fd09b0)Co-authored-by: ggqlq <124190229+ggqlq@users.noreply.github.com>
picnixz added a commit that referenced this pull requestMay 24, 2025
…tory` when serving over HTTPS (GH-134169) (#134630)[3.14]gh-134168: fix `http.server` CLI support for IPv6 and `--directory` when serving over HTTPS (GH-134169)(cherry picked from commit2fd09b0)Co-authored-by: ggqlq <124190229+ggqlq@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz approved these changes

Assignees

@picnixzpicnixz

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@ggqlq@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp