Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Connection#finished_request? #743

Merged
merged 3 commits into from
Mar 30, 2023
Merged

Conversation

c960657
Copy link
Contributor

@c960657 c960657 commented Mar 26, 2023

When using persistent connections there is no easy way to check if the entire body of the previous request has been consumed before sending a new request, e.g. if an exception was raised while reading the body.

Add Connection#finished? which does the same check as the guards in Connection#send_request.

def send_request(req)
if @pending_response
raise StateError, "Tried to send a request while one is pending already. Make sure you read off the body."
end
if @pending_request
raise StateError, "Tried to send a request while a response is pending. Make sure you read off the body."
end

lib/http/connection.rb Outdated Show resolved Hide resolved
Co-authored-by: Tony Arcieri <bascule@gmail.com>
@c960657 c960657 changed the title Add Connection#finished? Add Connection#finished_request? Mar 29, 2023
@tarcieri tarcieri merged commit 97aa636 into httprb:main Mar 30, 2023
@tarcieri
Copy link
Member

Thanks!

@c960657 c960657 deleted the connection-finished branch March 30, 2023 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants