-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automatically gzip compress content #654
Comments
Awesome! And it should check for |
Are you sure this issue has been solved fully and can be closed? The HTTP streams do not seem to be gzip-compressed automatically:
The HTTP request does contain
with the body size being the uncompressed original. So the streaming HTTP response is not being compressed on the fly. |
It'd be useful to automatically, by default, compress content for HTTP.Response ; this ticket is the opposite of #256 and complementary to #653 -- gzipping content could be done as part of the rendering process as the send buffer is filled (avoiding a literal copy of the user data). As the content is
printed
to an IO stream, it can be gzipped, and once the buffer is full, a chunked response could be sent for streams that exceed the buffer length.One of the challenges here is having a bypass for static content that is already compressed; for example, many resource bundles precompress their output so that you don't have to do it at runtime.
In a WSGI like stack, this is implemented as a
Response
proxy. Basically, it's a wrapper that, when you print the headers looks to see ifTransfer-Encoding
is already set, if so, it is a no-op. AFileResponse
object would notice that the file being served may have agzip
extension and start with the gzip chararaters and set the headers appropriately. The GzipResponse would then use thebody
of the wrapped response, reading or printing it, and gzipping the results. There are some advantages of being a proxy, but, it's not a necessary requirement for the design it could be built-in as a flag of some sort.The text was updated successfully, but these errors were encountered: