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

Replace ZipGenerator with ZipHandler #102

Merged
merged 1 commit into from
Mar 17, 2024
Merged

Conversation

julik
Copy link
Contributor

@julik julik commented Mar 12, 2024

Move more work into ZipKit, since it already handles the streaming body and the headers. What is important here is that we handle the files correctly - which is what the new ZipHandler will do, inside of the streaming ZipKit body. This reduces the number of interacting classes and objects and the number of conditionals.

ZipKit, in turn, will now not apply the chunked transfer encoding unless explicitly asked to. This is a follow-through on julik/zip_kit#2 because using ZipKit with an HTTP/2 webserver requires the transfer encoding to be disabled - HTTP/2 framing will be used instead. Following the suggestions from Samuel I have removed the chunking, but it is still possible to force it. Logging streaming exceptions is also easier now, as the entire block handling the ZIP is inside the each iteration. There is no tempfile spooling either because it changed the flow drastically (the file would write out at body instantiation, not at iteration over the response).

Note that this removes ZipGenerator, so user code that overrides it will require modification. The ZipHandler is way smaller though.

Move more work into ZipKit, since it already handles the streaming body and the headers. What is important here is that we handle the `files` correctly - which is what the new ZipHandler will do, inside of the streaming ZipKit body. This reduces the number of interacting classes and objects and the number of conditionals.

ZipKit, in turn, will now not apply the `chunked` transfer encoding unless explicitly asked to. This is a follow-through on julik/zip_kit#2 because using ZipKit with an HTTP/2 webserver requires the transfer encoding to be disabled - HTTP/2 framing will be used instead. Following the suggestions from Samuel I have removed the chunking, but it is still possible to force it. Logging streaming exceptions is also easier now, as the entire block handling the ZIP is inside the `each` iteration. There is no tempfile spooling either because it changed the flow drastically (the file would write out at body instantiation, not at iteration over the response)
@julik
Copy link
Contributor Author

julik commented Mar 17, 2024

@fringd wdyt?

@fringd
Copy link
Owner

fringd commented Mar 17, 2024

this looks good. merging... do you think this is worth making a major version bump? will the change to encoding potentially break some people on certain servers?

@fringd fringd merged commit a283c11 into fringd:master Mar 17, 2024
3 checks passed
@julik
Copy link
Contributor Author

julik commented Mar 17, 2024

I don't think it will, zipline wasn't applying the encoding previously and the change with zip_kit didn't get released yet. What may break is the fact that ZipGenerator is gone - and what is there in its place works differently. This does warrant a major version bump according to semver. For example, if folks have extended the ZipGenerator they will need to revise their code.

@julik
Copy link
Contributor Author

julik commented Mar 17, 2024

Sorry, if I wasn't clear - yes, we need a new major version 😉

@fringd
Copy link
Owner

fringd commented Mar 18, 2024

cool, just pushed 2.0.0! thanks again julik ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants