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 martin.panter, quentel, r.david.murray, terry.reedy, v+python, vstinner
Date 2017-07-22.20:48:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500756482.5.0.753897991521.issue30576@psf.upfronthosting.co.za>
In-reply-to
Content
Thank you Terry and Victor for your comments. I understand that you agree on adding HTTP compression to http.server, but don't want it to be enabled by default.

@terry.reedy

With the implementation proposed in the Pull Request, to disable compression by default, all it takes is to set the attribute SimpleHTTPRequestHandler.compressed_types to the empty list.

Users who want to enable compression for some types would create subclasses of Simple... that set compressed_types. For instance :

import http.server

class CompressedHandler(http.server.SimpleHTTPRequestHandler):

    compressed_types = ["text/html", "text/plain"]

http.server.test(HandlerClass=CompressedHandler)


Would that be ok ?

For a command line argument --gzip, compressed_types could be set to a list of commonly compressed types - I don't think we want to pass a list of types on the command line.

For CGI scripts, I may be missing something but for me it is up to the script to determine the response headers and content, I don't think a mixin class in http.server could help.

@haypo

I fully agree on your comment about content-length, the implementation in the PR is not optimal.

The alternative would be to send the answer using chunked transfer encoding, which is currently not used in http.server, and would also be relevant for other use cases than gzipped files. It shouldn't be difficult to add, and I volunteer to propose an implementation, but it's yet another feature to add to the server. Do you think it's relevant ?
History
Date User Action Args
2017-07-22 20:48:02quentelsetrecipients: + quentel, terry.reedy, vstinner, v+python, r.david.murray, martin.panter
2017-07-22 20:48:02quentelsetmessageid: <1500756482.5.0.753897991521.issue30576@psf.upfronthosting.co.za>
2017-07-22 20:48:02quentellinkissue30576 messages
2017-07-22 20:48:02quentelcreate