-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Brotli encoding is not recognized by mimetypes #76202
Comments
Brotli (.br) encoding is not recognized by mimetypes module. |
You can just add the encoding to mimetypes.encodings_map: mimetypes.encodings_map['.br'] = 'brotli' |
Yes, however would it make sense to add it, so mimetypes recognizes it by default? I will make a PR if it makes sense. |
It looks like Brotli is a de-facto standard (RFC 7932 is an informational RFC), and it says the IANA registry has been updated. However, this appears to be http-only, with no corresponding program used for compression of files, and thus no "file extension" to be registered, or program name to put in the encodings_map table. We don't have most of the types listed in the http content encodings registry in mimetypes, so I don't at this time see any reason to add br. mimetypes is aimed at files, not http. In what context do you want to use mimetimes to look up br? |
When "type, encoding = mimetypes.guess_type('file.js.br')" is used not only the "encoding" is not set to "brotli", but the type is also not recognized. My proposal is to add 'br' to mimetypes.encodings_map, not to mimetypes.types_map |
OK, so there are "real" filenames that have .br on the end? That wasn't clear from the RFC and discussions I found. Based on the documentation, br is for use in the Content-Encoding header. What does aiohttp do when it gets a brotli encoded file? What does it do with the other types in the http content-encoding table? (https://www.iana.org/assignments/http-parameters/http-parameters.xhtml#content-coding) Where is the standard that talks about the '.br' file extension? |
Note, I'm not saying we shouldn't do this, I'd just like to get good documentation of why linked to this issue. |
Currently aiohttp doesn't support Brotli. (I'm here because I would like to get that support) When it gets (as a server) a request for file.html it checks if file.html.gz exists (and accept-encoding contains 'gzip'). It then send file.html.gz to the client and sets Content-Encoding to gzip. It uses mimetypes.guess_type to set Content-Type and Content-Encoding. |
Hmm. OK, the docs do say that value should be usable as a content-encoding header. However, absent any sort of program that actually does brotli encoding/decoding to and from files, this would be essentially useless based on the aiohttp's algorithm (or any other use I can think of for the mimetimes module in this context). Does such a program exist? I didn't find one searching the web. |
NodeJS: https://www.npmjs.com/package/brotli That said I don't expect an average user to compress their files as .br, but it is useful for site/webapp developers to have static resources as .br |
OK, bouncing around from those URL I finally found this: That indicates unambiguously that someone does expect files to be pre-compressed on the server and that the main brotli package provides a cli tool (I could not find any reference to that in the brotli docs themselves, such as they are). So, I think it is appropriate to add this, and one can hope that the program name is indeed 'brotli' so that it matches up with the existing mimetypes docs :) |
Now that two years have passed, is there any additional info as to whether this should be added or not? It does seem that the format is active (https://github.com/google/brotli). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: