Message296417
Thanks for the comments. I agree with some of them, and have improved the PR accordingly, but I don't agree on the opinion that HTTP compression is beyond the scope of http.server : like browser cache (which also implies a negociation between client and server) it's a basic, normalized feature of HTTP servers ; it doesn't change the intention of "mapping requests to the directory structure", it just changes the way some files are served, improving transfer speed and network load, which is especially useful on mobile networks.
The implementation makes HTTP compression the default for the types defined in SimpleHTTPRequestHandler.compressed_types, but it can be disabled if the system can't handle it, like in the case you mention : just by setting compressed_types to the empty list. I have made it more clear in the documentation.
I understand the concern for HEAD requests, but they must return the same headers as GET, so the compression must be done to determine the content-length header.
To address the case when the tmp zone is limited, I have also added a try/except block that checks if the temporary gzipped file can be created ; if not, the file is returned uncompressed.
I don't understand Martin's suggestion to use HTTP compression for .gz files : they are already compressed, there wouldn't be any benefit to compress them again. It's the same for audio or video files. Compression is only useful for uncompressed data such as text files, scripts, css files, etc. that are not already compressed. All those files are sent unmodified and with their own content type.
I have also improved the PR for the alternative forms of Accept-Encoding ("gzip;q=0", "*", "GZIP", etc.). |
|
Date |
User |
Action |
Args |
2017-06-20 12:36:49 | quentel | set | recipients:
+ quentel, v+python, martin.panter |
2017-06-20 12:36:49 | quentel | set | messageid: <1497962209.9.0.715033851665.issue30576@psf.upfronthosting.co.za> |
2017-06-20 12:36:49 | quentel | link | issue30576 messages |
2017-06-20 12:36:49 | quentel | create | |
|