From: Thomas Maier Date: Tue, 14 Aug 2018 14:38:07 +0000 (+0200) Subject: ensure resp.Body is discarded to avoid broken tcp sockets (#348) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9a02cbf751629830cdf9147d0935abb8fdf2dc17;p=blackbox_exporter.git ensure resp.Body is discarded to avoid broken tcp sockets (#348) Signed-off-by: Thomas Maier --- diff --git a/prober/http.go b/prober/http.go index 5f2af69..bbc4543 100644 --- a/prober/http.go +++ b/prober/http.go @@ -296,7 +296,10 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr if err != nil && resp == nil { level.Error(logger).Log("msg", "Error for HTTP request", "err", err) } else { - defer resp.Body.Close() + defer func() { + io.Copy(ioutil.Discard, resp.Body) + resp.Body.Close() + }() level.Info(logger).Log("msg", "Received HTTP response", "status_code", resp.StatusCode) if len(httpConfig.ValidStatusCodes) != 0 { for _, code := range httpConfig.ValidStatusCodes {