This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author quentel
Recipients quentel
Date 2017-06-05.19:42:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496691724.59.0.955308322691.issue30576@psf.upfronthosting.co.za>
In-reply-to
Content
The server in http.server currently doesn't support HTTP compression.

I propose to implement it in the method send_head() of SimpleHTTPRequestHandler this way : for each GET request, if the request header "Accept-Encoding" is present and includes "gzip" among the possible compression schemes, and if the Content-Type determined by the file extension is in a list compressed_types, then the server sends the "Content-Encoding" response header to "gzip" and send_head() returns a file object with the gzipped value.

compressed_types is an attribute of the SimpleHTTPRequestHandler class and is set by default to ["text/plain", "text/html", "text/css", "text/xml", "text/javascript", "application/javascript", "application/json"].

The implementation is very simple (a few lines of code).

I also propose to modify mimetypes to add the mapping of extension ".json" to "application/json".

I will make a Pull Request on the CPython Github site with these changes.
History
Date User Action Args
2017-06-05 19:42:04quentelsetrecipients: + quentel
2017-06-05 19:42:04quentelsetmessageid: <1496691724.59.0.955308322691.issue30576@psf.upfronthosting.co.za>
2017-06-05 19:42:04quentellinkissue30576 messages
2017-06-05 19:42:04quentelcreate