Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/source/gitlab/client/client.go')
-rw-r--r--internal/source/gitlab/client/client.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/internal/source/gitlab/client/client.go b/internal/source/gitlab/client/client.go
index afe9da6f..ea7a6cf8 100644
--- a/internal/source/gitlab/client/client.go
+++ b/internal/source/gitlab/client/client.go
@@ -85,6 +85,15 @@ func (gc *Client) GetLookup(ctx context.Context, host string) api.Lookup {
return api.Lookup{Name: host}
}
+ // ensure that entire response body has been read and close it, to make it
+ // possible to reuse HTTP connection. In case of a JSON being invalid and
+ // larger than 512 bytes, the response body will not be closed properly, thus
+ // we need to close it manually in every case.
+ defer func() {
+ io.Copy(ioutil.Discard, resp.Body)
+ resp.Body.Close()
+ }()
+
lookup := api.Lookup{Name: host}
lookup.Error = json.NewDecoder(resp.Body).Decode(&lookup.Domain)