diff --git a/v2/pkg/engine/datasource/httpclient/nethttpclient.go b/v2/pkg/engine/datasource/httpclient/nethttpclient.go index d0aa73f59..518643c8a 100644 --- a/v2/pkg/engine/datasource/httpclient/nethttpclient.go +++ b/v2/pkg/engine/datasource/httpclient/nethttpclient.go @@ -203,15 +203,15 @@ func makeHTTPRequest(client *http.Client, ctx context.Context, url, method, head response, err := client.Do(request) - // Set response, even before error check, to ensure that it's in the context - setResponseStatus(ctx, request, response) - if err != nil { return err } defer response.Body.Close() + setResponseStatus(ctx, request, response) + respReader, err := respBodyReader(response) + if err != nil { return err }