retrieveDeviceAuth: Call r.Body.Close() #750
Open
+1
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close the response body after reading it in the DeviceAuth logic.
The
retrieveDeviceAuth
function did not close the response body. However, the net/http documentation states that one is expected to close the response body after one sends an HTTP request and reads the response body. In addition, thedoTokenRoundTrip
function does callr.Body.Close()
. (Some other functions use a client with a custom Transport that automatically closes the body, but that is not the case forretrieveDeviceAuth
ordoTokenRoundTrip
.)Follow-up to commit e3fb0fb.
I noticed the missing
r.Body.Close()
call while reviewing a vendor bump in a project that I help maintain. This project doesn't actually use DeviceAuth; I was just skimming through the newly vendored code when I noticed the questionable logic.