Skip to content

Commit

Permalink
Add Connection#finished_request? (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 authored Mar 30, 2023
1 parent 32a2ae6 commit 97aa636
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/http/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def close
@pending_request = false
end

def finished_request?
!@pending_request && !@pending_response
end

# Whether we're keeping the conn alive
# @return [Boolean]
def keep_alive?
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/http/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@
connection.read_headers!
buffer = String.new
while (s = connection.readpartial(3))
expect(connection.finished_request?).to be false if s != ""
buffer << s
end
expect(buffer).to eq "1234567890"
expect(connection.finished_request?).to be true
end
end
end

0 comments on commit 97aa636

Please sign in to comment.