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: adds custom default content-type to http.server by donbarbos · Pull Request #131000 · python/cpython

gh-113471: adds custom default content-type to http.server #131000

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.

Sign up for GitHub

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

Closed
donbarbos wants to merge 18 commits into python:main from donbarbos:issue-113471

Uh oh!

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

Closed

gh-113471: adds custom default content-type to http.server #131000

Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7848730
changeable default
jcomeauictx Dec 25, 2023
19cde54
ready to test
jcomeauictx Dec 25, 2023
e7860c3
passed test this time
jcomeauictx Dec 25, 2023
b945ced
DRY fix for #113471
jcomeauictx Dec 25, 2023
c2da505
📜🤖 Added by blurb_it.
blurb-it[bot] Dec 25, 2023
2f900fe
Merge branch 'main' into httpupgrade
jcomeauictx Dec 25, 2023
3486458
Merge branch 'main' into httpupgrade
jcomeauictx Dec 25, 2023
497f11e
Merge branch 'httpupgrade' of github.com:jcomeauictx/cpython into htt…
jcomeauictx Dec 27, 2023
48cdd20
Merge branch 'main' into httpupgrade
jcomeauictx Jan 4, 2024
d189051
Merge branch 'main' into httpupgrade
jcomeauictx Jan 13, 2024
4a6370b
Update Misc/NEWS.d/next/Library/2023-12-25-19-14-07.gh-issue-113471.Z…
jcomeauictx Jan 27, 2024
f7ff834
Merge branch 'httpupgrade' of github.com:jcomeauictx/cpython into htt…
jcomeauictx Jan 27, 2024
7ae00ea
removed short option and inefficiency pointed out by @serhiy-storchaka
jcomeauictx Jan 27, 2024
b9841d0
Merge branch 'main' into httpupgrade
jcomeauictx Jan 29, 2024
2ba2aee
adding tests per @serhiy_storchaka's suggestion, not all pass yet
jcomeauictx Jan 29, 2024
819491f
tests all pass
jcomeauictx Jan 29, 2024
2defce3
addresses some of @encukou's observations. still need to add tests.
jcomeauictx Feb 3, 2024
983a65b
Merge branch 'main' into issue-113471
donbarbos Mar 9, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view
Prev Previous commit
Next Next commit
adding tests per @serhiy_storchaka's suggestion, not all pass yet
  • Loading branch information

Uh oh!

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

@jcomeauictx
jcomeauictx committed Jan 29, 2024
commit 2ba2aeea781270aaa517110a7fb0bd8053e95f42

There are no files selected for viewing

20 changes: 20 additions & 0 deletions 20 Lib/http/server.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,26 @@ def guess_type(self, path):
as a default; however it would be permissible (if
slow) to look inside the data to make a better guess.

>>> testserver = type('', (), {
... 'makefile': lambda mode, bufsize: open(os.devnull, mode)
... })
>>> testhandler = SimpleHTTPRequestHandler(testserver, None, None)
>>> testhandler.guess_type('/foo.bar.GZ') # tests ext.lower()
'application/gzip'
>>> testhandler.default_content_type = 'nonesuch/nonesuch'
>>> testhandler.guess_type('/this/should/give/default')
'nonesuch/nonesuch'
>>> # check short-circuiting works
>>> mimetypes = type('', (), {
... 'guess_type': lambda x: (print('foo'), print('bar'))
... })
>>> testhandler.guess_type('/should/show/foo/bar/then/default')
foo
bar
'nonesuch/nonesuch'
>>> testhandler.guess_type('/should/not/print/foo.Z')
'application/octet-stream'

"""
base, ext = posixpath.splitext(path)
return self.extensions_map.get(ext) or \
Expand Down
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 01402520 — 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.