GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-113471: Add custom default Content-Type to http.server by jcomeauictx · Pull Request #113475 · python/cpython

Conversation

@jcomeauictx

@jcomeauictx jcomeauictx commented Dec 25, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: default http content-type #113471

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jcomeauictx added 4 commits December 25, 2023 14:57
@jcomeauictx
changeable default
7848730
@jcomeauictx
ready to test
19cde54
@jcomeauictx
passed test this time
e7860c3
@jcomeauictx
DRY fix for python#113471
b945ced
@ghost

ghost commented Dec 25, 2023 •
edited by ghost
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Dec 25, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Dec 25, 2023
@bedevere-app bedevere-app Bot mentioned this pull request Dec 25, 2023
default http content-type #113471
Closed
blurb-it Bot and others added 6 commits December 25, 2023 19:14
@blurb-it
📜🤖 Added by blurb_it.
c2da505
@jcomeauictx
Merge branch 'main' into httpupgrade
2f900fe
@jcomeauictx
Merge branch 'main' into httpupgrade
3486458
@jcomeauictx
Merge branch 'httpupgrade' of github.com:jcomeauictx/cpython into htt…
497f11e
…pupgrade
@jcomeauictx
Merge branch 'main' into httpupgrade
48cdd20
@jcomeauictx
Merge branch 'main' into httpupgrade
d189051
serhiy-storchaka
serhiy-storchaka reviewed Jan 26, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This change need tests.

I am not sure how much useful is this feature. It only allows to override the MIME type of unrecognized types. And would not it be simpler to configure your browser?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/http/server.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/http/server.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Library/2023-12-25-19-14-07.gh-issue-113471.ZQMpbI.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

jcomeauictx and others added 6 commits January 27, 2024 04:40
@jcomeauictx @serhiy-storchaka
Update Misc/NEWS.d/next/Library/2023-12-25-19-14-07.gh-issue-113471.Z…
4a6370b
…QMpbI.rst

Co-authored-by: Serhiy Storchaka <[email protected]>
@jcomeauictx
Merge branch 'httpupgrade' of github.com:jcomeauictx/cpython into htt…
f7ff834
…pupgrade
@jcomeauictx
removed short option and inefficiency pointed out by @serhiy-storchaka
7ae00ea
@jcomeauictx
Merge branch 'main' into httpupgrade
b9841d0
@jcomeauictx
adding tests per @serhiy_storchaka's suggestion, not all pass yet
2ba2aee
@jcomeauictx
tests all pass
819491f
encukou
encukou reviewed Feb 2, 2024
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The feature looks useful to me; I've wanted it once or twice before. However, adding it would be a lot work. Not sure if it's worth your time.

The change needs documentation (in Doc/library/http.server.rst, both for the attribute and CLI option).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jcomeauictx reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Comment thread Lib/http/server.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/http/server.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx
addresses some of @encukou's observations. still need to add tests.
2defce3
@encukou encukou added awaiting changes and removed awaiting review labels Apr 15, 2024
@donbarbos

donbarbos commented Mar 8, 2025

Copy link
Copy Markdown
Contributor

@jcomeauictx are you going to continue working on this PR?

jcomeauictx reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx

jcomeauictx commented Mar 8, 2025

Copy link
Copy Markdown
Contributor Author

@jcomeauictx are you going to continue working on this PR?

I've forgotten what else needs to be done. And in any case, nobody else seems interested in it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

donbarbos
donbarbos reviewed Mar 8, 2025
View reviewed changes
Comment thread Doc/library/http.server.rst Outdated

python -m http.server --default-content-type text/html

.. versionchanged:: 3.13

@donbarbos donbarbos Mar 8, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
.. versionchanged:: 3.13
.. versionchanged:: next

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@donbarbos

donbarbos commented Mar 8, 2025

Copy link
Copy Markdown
Contributor

I've forgotten what else needs to be done. And in any case, nobody else seems interested in it.

I'm interested :)
I think if you add tests you can ping someone from core members

jcomeauictx reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx

jcomeauictx commented Mar 8, 2025

Copy link
Copy Markdown
Contributor Author

OK, I'll look into it tomorrow. No idea where to add them, though, or what precisely needs to be tested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx
corrected double hyphen
6fa0a6d
@jcomeauictx

jcomeauictx commented Mar 16, 2025 via email

Copy link
Copy Markdown
Contributor Author
"move the description of this flag to the right place", what does that mean? Could you please do it? I just corrected the hyphenation.
…
On Sun, Mar 16, 2025 at 6:10 AM donBarbos ***@***.***> wrote: ***@***.**** commented on this pull request. ------------------------------ In Doc/library/http.server.rst <#113475 (comment)>: > +By default, the server uses the MIME type ``'application/octet-stream'`` for +the ``Content-Type`` header when the content type cannot be guessed from the +URL's extension (if any). The option ``--default-content-type`` overrides +this default with one of the user's choosing:: + + python -m http.server --default-content-type text/html + +.. versionchanged:: next + Added the ``--default-content-type`` option. @jcomeauictx <https://github.com/jcomeauictx> we added usage of .. option:: directory for CLI flags, we also need to move the description of this flag to the right place, could you move it? (I also forgot the second - before default-content-type, please add it :) — Reply to this email directly, view it on GitHub <#113475 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABRUXUAWLKM3YQ2WNDDTZL2UVZ5XAVCNFSM6AAAAABYSPI2O6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMOBYGY3DSNJZGA> . You are receiving this because you were mentioned.Message ID: ***@***.***>
-- John Comeau KE5TFZ WSEE965 ***@***.***> ***@***.***> http://jc.unternet.net/ "A place for everything, and everything all over the place"
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@donbarbos

donbarbos commented Mar 16, 2025

Copy link
Copy Markdown
Contributor

Sorry I can't. I mean move on to the rest options

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx
moved to options section
afe8ebb
@jcomeauictx

jcomeauictx commented Mar 16, 2025 via email

Copy link
Copy Markdown
Contributor Author
OK, please check that I did it right.
…
On Sun, Mar 16, 2025 at 7:59 AM donBarbos ***@***.***> wrote: Sorry I can't. I mean move on to the rest options — Reply to this email directly, view it on GitHub <#113475 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABRUXV7CQROXHJA4WOQ2N32UWGTPAVCNFSM6AAAAABYSPI2O6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRXGQ4DKNRZHE> . You are receiving this because you were mentioned.Message ID: ***@***.***> [image: donBarbos]*donBarbos* left a comment (python/cpython#113475) <#113475 (comment)> Sorry I can't. I mean move on to the rest options — Reply to this email directly, view it on GitHub <#113475 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABRUXV7CQROXHJA4WOQ2N32UWGTPAVCNFSM6AAAAABYSPI2O6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRXGQ4DKNRZHE> . You are receiving this because you were mentioned.Message ID: ***@***.***>
-- John Comeau KE5TFZ WSEE965 ***@***.***> ***@***.***> http://jc.unternet.net/ "A place for everything, and everything all over the place"
donbarbos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 15, 2026
hugovk added 3 commits April 15, 2026 14:48
@hugovk
Merge remote-tracking branch 'upstream/main' into httpupgrade
9b85d26
@hugovk
fixup! Merge remote-tracking branch 'upstream/main' into httpupgrade
ef13b83
@hugovk
Whitespace
9ee3295
@hugovk hugovk changed the title gh-113471: adds custom default content-type to http.server gh-113471: Add custom default Content-Type to http.server Apr 15, 2026
hugovk added 3 commits April 15, 2026 15:01
@hugovk
Update docs to match code: --content-type
fba0c78
@hugovk
Update docs to match code: args order
2351c85
@hugovk
Fix docs indent to match others
1cb71b8
@hugovk

hugovk commented Apr 15, 2026

Copy link
Copy Markdown
Member

I've resolved the merge conflict and pushed some minor docs things.


default_content_type is defined on BaseHTTPRequestHandler, but only used in its subclass SimpleHTTPRequestHandler, in guess_type().

Should default_content_type be moved to SimpleHTTPRequestHandler?

Also, test() defaults HandlerClass=BaseHTTPRequestHandler, but the CLI calls it with HandlerClass=SimpleHTTPRequestHandler.

test() then sets HandlerClass.default_content_type. This doesn't matter to BaseHTTPRequestHandler if we move it, although we could also change test() to only use SimpleHTTPRequestHandler?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jcomeauictx

jcomeauictx commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

I think I had a reason to put it in BaseRequestHandler, but it's been a long time and I've moved on to other things. Do what seems best.

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk approved these changes Apr 15, 2026
View reviewed changes
Comment thread Doc/library/http.server.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/http.server.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting changes labels Apr 15, 2026
hugovk added 2 commits April 15, 2026 18:29
@hugovk
Update docs formatting and caps
aaafba8
Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk
Move default_content_type to SimpleHTTPRequestHandler
5034413
@read-the-docs-community

read-the-docs-community Bot commented Apr 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32468450 | 📁 Comparing 4388da5 against main (69e0a78)

  🔍 Preview build  

8 files changed · ± 8 modified

± Modified

  • download.html
  • genindex-D.html
  • genindex-H.html
  • genindex-Symbols.html
  • genindex-all.html
  • library/http.server.html
  • whatsnew/3.15.html
  • whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk added 3 commits April 29, 2026 16:24
@hugovk
Add test
c475fec
@hugovk
Update docs
1c4496d
@hugovk
Add to What's New
4388da5
@hugovk
hugovk requested a review from AA-Turner as a code owner April 29, 2026 13:33
hugovk
hugovk approved these changes Apr 29, 2026
View reviewed changes
@hugovk
hugovk merged commit cc5f8b5 into python:main Apr 30, 2026
51 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Apr 30, 2026

Copy link
Copy Markdown
Member

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@picnixz picnixz picnixz requested changes
@hugovk hugovk hugovk approved these changes
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
+1 more reviewer
@donbarbos donbarbos donbarbos left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@jcomeauictx @donbarbos @hugovk @encukou @serhiy-storchaka @picnixz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.