Skip to content

Commit

Permalink
Closing the body after hijack
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Zhuravsky authored and ioquatix committed Apr 5, 2024
1 parent 418ca04 commit 73c6b38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/async/http/protocol/http1/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def each(task: Task.current)
response = yield(request, self)
body = response&.body

return if hijacked?
if hijacked?
body&.close
return
end

task.defer_stop do
# If a response was generated, send it:
Expand Down
2 changes: 1 addition & 1 deletion test/async/http/protocol/http11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def around
end

it "works properly" do
expect(body).not.to receive(:close)
expect(body).to receive(:close)

response = client.get("/")

Expand Down

0 comments on commit 73c6b38

Please sign in to comment.