Skip to content

gh-85162: Add HTTPSServer to http.server #129607

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 54 commits into from
Apr 5, 2025
Merged

Conversation

donBarbos
Copy link
Contributor

@donBarbos donBarbos commented Feb 3, 2025

I decided to resume the work on the implementation of HTTPS server in http.server module.
I am ready to respond in time and make changes :-)

I'm opening a new PR because this #20923 had been clearly abandoned.

I took the liberty of defining a single style in Lib/http/server.py file, otherwise everything would have been completely confusing.

cc @tiran @remilapeyre @jaswdr
(who was involved with the previous PR)


📚 Documentation preview 📚: https://cpython-previews--129607.org.readthedocs.build/

@donBarbos donBarbos changed the title gh-85162: Add HTTPS support to http.server.HTTPServer gh-85162: Add HTTPSServer to http.server Feb 3, 2025
picnixz
picnixz previously requested changes Feb 3, 2025
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but I can't review what is new and necessary from what is not (even with separate commits). While the style is inconsistent, let's address it in a separate PR if it's really that disturbing.

Note that since we sqash-merge at the end, the style changes will be part of the diff as well making the history harder to review.

@bedevere-app
Copy link

bedevere-app bot commented Feb 3, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

This reverts commit b382985.
@donBarbos
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented Feb 3, 2025

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from picnixz February 3, 2025 14:17
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface doesn't look the nicest to me. Is there an obvious reason why we can't add SSL support to HTTPServer even though it's named HTTPServer? Or should we really make HTTPSServer inherit from HTTPServer?

I am travelling and it's hard to review on mobile but @gpshead may have some preliminary comments on the design. I've left some comments but they can be disregarded for now until the design is fixed.

@donBarbos
Copy link
Contributor Author

donBarbos commented Feb 3, 2025

@picnixz
Initially, I was guided by the comment left by @tiran in the previous PR:
#20923 (review)

I don't want to change the HTTP server interface and overcomplicate it. I also think this matches the principle of separation of responsibilities.

but I'm open to discussion

@picnixz
Copy link
Member

picnixz commented Feb 3, 2025

Ok for a separate class but whether it should be a subclass or not is something I don't know if we should do. I don't know which layout will be the best one in the long term (for now let's keep it as a subclass).

I don't think I have thought enough about the broader implications so I will hold future reviews for now. I think I need another opinion on this interface (btw, I'm not sure tiran is still active actually, hence the reason why I requested gpshead's opinion).

@donBarbos donBarbos requested a review from picnixz February 3, 2025 20:25
Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regardless of review, I still wonder if we actually want this in the stdlib? But the implementation is not complicated so I don't think it'll be a maintenance burden in that regard.

The challenge is it may add more reasons for people to file security issues. Despite our existing bold warning up top in https://docs.python.org/3.14/library/http.server.html that http.server is not a production quality secure server.

@donBarbos
Copy link
Contributor Author

I think it's important to add this because there are many useful use cases.
all such people first go to the documentation before opening an issue.

And I don't see any reason why they would open an issue if they were already familiar with the concept of http.server

@donBarbos donBarbos requested a review from gpshead February 4, 2025 08:56
@donBarbos
Copy link
Contributor Author

@gpshead what do you think now about the merge of this PR?

@donBarbos donBarbos requested a review from picnixz March 16, 2025 11:27
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I missed one possible case

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an improved blurb/what's new and I think it's good to go.

@picnixz
Copy link
Member

picnixz commented Apr 4, 2025

I'll let it open a few days so that @gpshead can have a look, else I'll merge this before the end of the week.

@picnixz picnixz enabled auto-merge (squash) April 5, 2025 08:26
@picnixz picnixz disabled auto-merge April 5, 2025 08:26
@picnixz picnixz enabled auto-merge (squash) April 5, 2025 08:28
@picnixz picnixz merged commit 37bc386 into python:main Apr 5, 2025
38 checks passed
@donBarbos
Copy link
Contributor Author

Thanks a lot everyone

seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
…r HTTPS (python#129607)

The `http.server` module now supports serving over HTTPS using the `http.server.HTTPSServer` class.
This functionality is also exposed by the command-line interface (`python -m http.server`) through the
`--tls-cert`, `--tls-key` and `--tls-password-file` options.
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.

3 participants