[New-bugs-announce] [issue30576] http.server should support HTTP compression (gzip)

Pierre Quentel report at bugs.python.org
Mon Jun 5 15:42:04 EDT 2017


New submission from Pierre Quentel:

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.

----------
components: Library (Lib)
messages: 295207
nosy: quentel
priority: normal
severity: normal
status: open
title: http.server should support HTTP compression (gzip)
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30576>
_______________________________________


More information about the New-bugs-announce mailing list