Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Merge 9ff4a9c into 020de4d
Browse files Browse the repository at this point in the history
  • Loading branch information
Mask committed Jan 11, 2015
2 parents 020de4d + 9ff4a9c commit 0363861
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/reel/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def respond(response, headers_or_body = {}, body = nil)
# The client disconnected early, or there is no request
@keepalive = false
@request_fsm.transition :closed
@parser.reset
@current_request = nil
end

# Close the connection
Expand Down
19 changes: 19 additions & 0 deletions spec/reel/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ def test_chunked_response(request, client)
end
end

it "resets if client dropped connection" do
with_socket_pair do |client, peer|
connection = Reel::Connection.new(peer)
example_request = ExampleRequest.new
client << example_request

expect(connection.request).not_to be_nil

client.close # client drops connection
# now send more than the send buffer can hold, triggering a
# error (ECONNRESET or EPIPE)
connection.respond :ok, ("Some Big Response sent"*100000)

# connection should be at end
expect(connection.request).to be_nil
end
end


it "raises an error trying to read two pipelines without responding first" do
with_socket_pair do |client, peer|
connection = Reel::Connection.new(peer)
Expand Down

0 comments on commit 0363861

Please sign in to comment.