Fix HTTP::Server::Response#close
when replaced output syncs close
#11631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 checksself.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 byResponse::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