Skip to content

[3.14] gh-134168: fix http.server CLI support for IPv6 and --directory when serving over HTTPS (#134169) #134630

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

Merged
merged 1 commit into from
May 24, 2025

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented May 24, 2025

@picnixz
Copy link
Member Author

picnixz commented May 24, 2025

@ggqlq Can you check that this works on 3.14 (not 3.15). It should work but we never know. TiA. For this one, can you check both IPv4 and IPv6?

…-directory` when serving over HTTPS (pythonGH-134169)

(cherry picked from commit 2fd09b0)

Co-authored-by: ggqlq <124190229+ggqlq@users.noreply.github.com>
@picnixz picnixz force-pushed the backport-2fd09b0-3.14 branch from b931d45 to 06f32d7 Compare May 24, 2025 12:50
@picnixz
Copy link
Member Author

picnixz commented May 24, 2025

(I forced push because I wanted the cherry-picker message (I managed to make it work))

@ggqlq
Copy link
Contributor

ggqlq commented May 24, 2025

All passed!
(based on 06f32d7)

IPv4 + SSL

$ ./python -m http.server -b 127.0.0.1 --tls-cert ~/ssl/localhost.crt --tls-key ~/ssl/localhost.key
Serving HTTPS on 127.0.0.1 port 8000 (https://127.0.0.1:8000/) ...

$ curl -k https://127.0.0.1:8000
# ...
<ul>
<li><a href=".azure-pipelines/">.azure-pipelines/</a></li>
<li><a href=".coveragerc">.coveragerc</a></li>

IPv4 + other directory

$ ./python -m http.server -b 127.0.0.1 -d ~/test
Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...

$ curl http://127.0.0.1:8000
# ...
<ul>
<li><a href="1">1</a></li>
<li><a href="2">2</a></li>
<li><a href="3">3</a></li>

IPv4 + other directory + SSL

$ ./python -m http.server -b 127.0.0.1 --tls-cert ~/ssl/localhost.crt --tls-key ~/ssl/localhost.key -d ~/test
Serving HTTPS on 127.0.0.1 port 8000 (https://127.0.0.1:8000/) ...

$ curl -k https://127.0.0.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

$ ./python -m http.server -b ::1 --tls-cert ~/ssl/localhost.crt --tls-key ~/ssl/localhost.key
Serving 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

$ ./python -m http.server -b ::1 -d ~/test
Serving 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 + other directory + SSL

$ ./python -m http.server -b ::1 --tls-cert ~/ssl/localhost.crt --tls-key ~/ssl/localhost.key -d ~/test
Serving 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 picnixz merged commit 81f0993 into python:3.14 May 24, 2025
41 checks passed
@picnixz picnixz deleted the backport-2fd09b0-3.14 branch May 25, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants