fix: close response body and fix memory leak
What does this MR do?
fixes a few memory leaks I bumped into while reviewing the code:
-
makeRequest
: this was documented so it's an easy fix, see https://gitlab.com/gitlab-org/gitlab-pages/-/blob/master/internal/handlers/handlers.go#L65-L66 -
fetchAccessToken
: this was more tricky, ifStatusCode
is not 200 (OK) the method returns early and the body is never closed -
checkAuthentication
: the statement is missing and the body is never closed*
*technically, the body is closed inside checkResponseForInvalidToken which is called here. However the logic is run only if status code is StatusUnauthorized
.
TODO
-
I added the Changelog
trailer (e.g.Changelog: feature
) to the commits that need to be included in the changelog -
I added unit tests or they are not required -
I added acceptance tests or they are not required -
I added documentation (or it's not required) -
I followed code review guidelines -
I followed Go Style guidelines
Related to %{ISSUE_ID}