Skip to content

Commit 8499b41

Browse files
committed
retrieveDeviceAuth: Call r.Body.Close()
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, the doTokenRoundTrip function *does* call r.Body.Close(). (Some other functions use a client with a custom Transport that automatically closes the body, but that is not the case for retrieveDeviceAuth or doTokenRoundTrip.) Follow-up to commit e3fb0fb. * deviceauth.go (retrieveDeviceAuth): Call r.Body.Close() after reading r.Body.
1 parent 22134a4 commit 8499b41

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

deviceauth.go

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func retrieveDeviceAuth(ctx context.Context, c *Config, v url.Values) (*DeviceAu
111111
return nil, err
112112
}
113113

114+
defer r.Body.Close()
114115
body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20))
115116
if err != nil {
116117
return nil, fmt.Errorf("oauth2: cannot auth device: %v", err)

0 commit comments

Comments
 (0)