http prober: Fix error checking (#723)
authorJulien Pivotto <roidelapluie@inuits.eu>
Mon, 14 Dec 2020 23:14:43 +0000 (00:14 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Dec 2020 23:14:43 +0000 (23:14 +0000)
Not sure if that can be triggered in real scenarios.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
prober/http.go

index 125b508089197bc1e9728cd6363342591d618298..5452fa18b9198180efc674fd7d3e23ace6095c8f 100644 (file)
@@ -412,12 +412,12 @@ func ProbeHTTP(ctx context.Context, target string, module config.Module, registr
        }
 
        request, err := http.NewRequest(httpConfig.Method, targetURL.String(), body)
-       request.Host = origHost
-       request = request.WithContext(ctx)
        if err != nil {
                level.Error(logger).Log("msg", "Error creating request", "err", err)
                return
        }
+       request.Host = origHost
+       request = request.WithContext(ctx)
 
        for key, value := range httpConfig.Headers {
                if strings.Title(key) == "Host" {