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

Fix HTTP::Server::Response#close when replaced output syncs close #11631

Merged

Conversation

straight-shoota
Copy link
Member

This patch fixes a regression introduced in #11253

The mechanics of the bug are described in #11389 (comment). The fix simply replaces check_open (which checks self.closed? -> output.closed?) by @original_output.closed? which is more accurate in this case.

output IO only affects the response body. We don't care about that when checking if headers can be written. The headers are part of the HTTP message and as such written directly to the underlying io (@io). Checking if @io is closed doesn't make sense because it's usually kept alive between requests. The abstraction of that part of @io that is attached to the response is represented by Response::Output, which is accessible as @original_output.

The overall structure of HTTP::Server::Response and its IOs seems a bit convoluted. I hope this can be refactored for simplicity. But that's a follow-up task.

Resolves #11389

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking kind:regression Something that used to correctly work but no longer works labels Dec 21, 2021
Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@beta-ziliani beta-ziliani added this to the 1.3.0 milestone Dec 21, 2021
@straight-shoota straight-shoota changed the title Fix HTTP::Server::Response#close when replaced output syncs close Fix HTTP::Server::Response#close when replaced output syncs close Dec 21, 2021
@straight-shoota straight-shoota merged commit 1565328 into crystal-lang:master Dec 22, 2021
@straight-shoota straight-shoota deleted the fix/http-response-output branch December 22, 2021 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:stdlib:networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Closed stream error when using GZip on 1.3.0.dev
2 participants