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

Close connections #164

Merged
merged 2 commits into from
May 26, 2023
Merged

Close connections #164

merged 2 commits into from
May 26, 2023

Conversation

fujiwara
Copy link
Contributor

@fujiwara fujiwara commented Aug 4, 2021

Hi. This PR enables close test connections and HTTP response.

dockerize keeps a test TCP connection while running, but if the server cannot accept multiple TCP connections, the test connection fills the server's slot. It should be closed.

dockerize does not read HTTP response body and does not close it now.
When an unread response body exists, http.Client cannot reuse the TCP connection for the next request.

When an unread response body exists, http.Client cannot reuse
the TCP connection for the next request.
If the server cannot accept multiple TCP connections,
dockerize's test connection fills the server's slot.
Test connection should be closed.
Copy link
Contributor

@ruudk ruudk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, why not immediately call resp.Body.Close() after resp, err := client.Do(req)?

@fujiwara
Copy link
Contributor Author

  1. If close the body without reading, the http.Client cannot reuse the TCP connection.
  2. When client.Do() returns error, resp.Body may be nil. Calling Close() raise a panic.

@ruudk
Copy link
Contributor

ruudk commented Sep 10, 2021

Thanks, TIL 😊

@jwilder jwilder merged commit f55ebe3 into jwilder:master May 26, 2023
@fujiwara fujiwara deleted the close-connections branch May 27, 2023 06:11
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.

3 participants