Skip to content
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

flush() after writing to gzip_file #2753

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

flush() after writing to gzip_file #2753

wants to merge 2 commits into from

Commits on Nov 15, 2024

  1. flush() after writing to gzip_file

    In order to better support streaming responses where the chunks are smaller than the file buffer size, we flush after writing.
    
    Without the explicit flush, the writes are buffered and the subsequent reads see an empty self.gzip_buffer until the file automatically flushes due to either
    (1) the write buffer fills, probably at 8kiB, or (2) the file is closed because the streaming response is complete.
    
    Without flushing, the GZipMiddleware doesn't work as expected for streaming responses, especially not for Server-Sent Events which are expected to be delivered immediately to clients. The code as written appears to intend to flush immediately rather than buffering, as it does immediately call `await self.send(message)`, but in practice that `message` is often empty.
    vin authored Nov 15, 2024
    Configuration menu
    Copy the full SHA
    f1b1ef8 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2024

  1. Configuration menu
    Copy the full SHA
    2450b70 View commit details
    Browse the repository at this point in the history