Skip to content

Commit

Permalink
Return body on upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 28, 2024
1 parent 9cfcbd7 commit dfcacca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/protocol/http1/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ def read_request_body(method, headers)
return read_tunnel_body
end

# A successful upgrade response implies that the connection will become a tunnel immediately after the empty line that concludes the header fields.
if headers[UPGRADE]
return read_tunnel_body
end

# 6. If this is a request message and none of the above are true, then
# the message body length is zero (no message body is present).
return read_body(headers)
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/http1/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

expect(version).to be == request_version
expect(headers['upgrade']).to be == [protocol]
expect(body).to be_nil
expect(body).to be_a(Protocol::HTTP1::Body::Remainder)

stream = server.hijack!
expect(stream.read).to be == "Hello World"
Expand Down

0 comments on commit dfcacca

Please sign in to comment.