…ler.extensions_map
There was a problem hiding this comment.
A couple of things to fix, but view my suggestion on the bug in case you like my next idea better :)
| extensions_map = { | ||
| '': 'application/octet-stream', # Default, | ||
| **mimetypes.types_map | ||
| } |
There was a problem hiding this comment.
This is missing the .py, .c and .h defaults as well. They certainly aren't guaranteed to be available.
There was a problem hiding this comment.
Oh, I didn't see that types_map is already partially initialized. This bit is fine then - leave it as it is.
| """ | ||
| if not mimetypes.inited: | ||
| mimetypes.init() # try to read system mime.types | ||
| self.extensions_map.update(mimetypes.types_map) |
There was a problem hiding this comment.
This is actually going to update in the wrong order - it will overwrite any manual overrides with the original type.
There was a problem hiding this comment.
it will overwrite any manual overrides with the original type
By manual overrides, are you talking about the '': 'application/octet-stream' pair?
Maybe we should replace this line with:
self.extensions_map = {
'': 'application/octet-stream',
**mimetypes.types_map
}What do you think?
|
@onyb Did you had time to check for https://bugs.python.org/issue35292#msg331739? I actually think the idea is good. |
|
The fix in #17822 makes this one unnecessary. Thanks for working on it, though! |
Important changes
extension_mapclass attribute ofSimpleHTTPRequestHandleris initialized with a default mapping, and some static mapping already available inmimetypes.types_map.SimpleHTTPRequestHandler.guess_typemethod..pyextension is nowtext/x-pythoninstead oftext/plain.https://bugs.python.org/issue35292