- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
gh-113471: adds custom default content-type to http.server #113475
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
base: main
Are you sure you want to change the base?
Conversation
| 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  | 
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?
        
          
                Misc/NEWS.d/next/Library/2023-12-25-19-14-07.gh-issue-113471.ZQMpbI.rst
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …QMpbI.rst Co-authored-by: Serhiy Storchaka <[email protected]>
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).
| @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. | 
        
          
                Doc/library/http.server.rst
              
                Outdated
          
        
      |  | ||
| python -m http.server --default-content-type text/html | ||
|  | ||
| .. versionchanged:: 3.13 | 
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.
| .. versionchanged:: 3.13 | |
| .. versionchanged:: next | 
| 
 I'm interested :) | 
| OK, I'll look into it tomorrow. No idea where to add them, though, or what precisely needs to be tested. | 
| we have at least two test classes where  | 
| I've looked at  | 
| 
 yea, thank you. I will try to send suggestion as soon as possible. | 
| @jcomeauictx could you merge main branch for correct tests? | 
| done, I think? also changed  | 
| @jcomeauictx could you merge  | 
| cc @picnixz what do you think about this feature? | 
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.
I won't comment of the usefulness as I don't think I'll ever use it but the feature seems easy to implement so I'll accept the work. However, we need:
- tests
- a What's Newentry (inDoc/whatsnew/3.14.rst; locate thehttp.serversection inImproved Modules, or create one if none exists and carefully write it in the same style as other sections do)
        
          
                Misc/NEWS.d/next/Library/2023-12-25-19-14-07.gh-issue-113471.ZQMpbI.rst
              
                Outdated
          
            Show resolved
            Hide resolved
        
      Co-authored-by: Bénédikt Tran <[email protected]>
…QMpbI.rst Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
Co-authored-by: donBarbos <[email protected]>
| donBarbos, I just added it, but isn't the indentation wrong? | 
| "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" | 
| Sorry I can't. I mean move on to the rest options | 
| 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" | 
Uh oh!
There was an error while loading. Please reload this page.