-
Notifications
You must be signed in to change notification settings - Fork 363
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
Cannot close response when it wasn't read until EOF #214
Comments
Maybe we should have a function implementing |
That would be perfect! |
After some testing, I found out where the problem is. It's on the |
The biggest problem for me is it just hangs. It doesn't return an error. It's just a hang. I'm trying to see if I can come up with a testable solution to make a PR with a fix! |
Strangely enough, // A ProtocolError describes a protocol violation such
// as an invalid response or a hung-up connection.
type ProtocolError string |
Darn... After analysing even further, I see implementing The timeline of aborting an incomplete
The timeline of aborting a complete
Correct me if I'm wrong but this seems to imply a few things:
So a small rework would probably be needed in order to, for example, remove some of the P.S.: I'm sorry for the long text |
Just read into io.Discard in Close? |
Describe the bug
Calling
response.Close()
never returns.To Reproduce
Make a
Retr
request and close the response without reading everything until EOF (i.e.: read just a few bytes but not the whole file).Expected behavior
response.Close()
returns without an error.Additional context
I was able to """fix""" this by putting
_, _ = io.Copy(ioutil.Discard, retrResponse)
before the close call. This way the rest of the file was read and discarded so then it could be closed.From what I can gather, this library doesn't handle closing the response if it wasn't read all the way through until the end. Reading the whole file before closing is just a waste of time and resources so my workaround should only be used as a hack to get this to work and probably not in production.
The text was updated successfully, but these errors were encountered: