[Python-ideas] HTTP compression support for http.server

Terry Reedy tjreedy at udel.edu
Thu Jul 20 15:11:38 EDT 2017


On 7/20/2017 3:15 AM, Pierre Quentel wrote:
> I have reported an issue in the tracker 
> (https://bugs.python.org/issue30576) and proposed a Pull Request on the 
> Github CPython repository (https://github.com/python/cpython/pull/2078) 
> to make http.server in the standard library support HTTP compression (gzip).

Full response on the issue.  Briefly

> I have been suggested to require feedback from core devs :
> - should HTTP compression be supported ?

Yes.

> - if so, should it be supported by default ?

No, contrary to painfully wrought policy.

> It is the case in the PR, 
> where a number of content types, eg text/html, are compressed if the 
> user agent accepts the gzip "encoding"
> - if not, should the implementation of http.server be adapted so that 
> subclasses could implement it ? For the moment the only way to add it is 
> to modify method send_head() of SimpleHTTPRequestHandler

Add subclass.

> My opinion is that it should be supported : http.server is not meant to 
> be a full-featured HTTP server, but compression it is a basic and 
> normalized feature of HTTP servers, it is supported by most browsers 
> including on smartphones, it reduces network load, and it's very easy to 
> implement (cf. the Pull Request). For the same reason, I recently added 
> browser cache to http.server (PR #298 
> <https://github.com/python/cpython/pull/298>).
> 
> I also think that it should be supported by default for the most common 
> content types (text/html, text/css, application/javascript...) ; the 
> implementation is based on a list of types to compress 
> (SimpleHTTPServer.compressed_types) that can be modified at will, eg set 
> to the empty list to disable compression.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list