"github.com/prometheus/blackbox_exporter/config"
)
-var caser = cases.Title(language.Und)
-
func matchRegularExpressions(reader io.Reader, httpConfig config.HTTPProbe, logger log.Logger) bool {
body, err := ioutil.ReadAll(reader)
if err != nil {
return false
}
+ // Do not move the following variable to global scope. The cases.Caser returned by
+ // calling cases.Title *cannot* be shared among goroutines. This might happen when
+ // Prometheus tries to scrape multiple targets at the same time. From the docs:
+ //
+ // A Caser may be stateful and should therefore not be shared between goroutines.
+ //
+ // Issue: https://github.com/prometheus/blackbox_exporter/issues/922
+
+ caser := cases.Title(language.Und)
+
httpClientConfig := module.HTTP.HTTPClientConfig
if len(httpClientConfig.TLSConfig.ServerName) == 0 {
// If there is no `server_name` in tls_config, use
"github.com/go-kit/log"
"github.com/prometheus/client_golang/prometheus"
pconfig "github.com/prometheus/common/config"
+ "golang.org/x/text/cases"
+ "golang.org/x/text/language"
"github.com/prometheus/blackbox_exporter/config"
)
"Accept-Language": "en-US",
}
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ caser := cases.Title(language.Und)
for key, value := range headers {
if caser.String(key) == "Host" {
if r.Host != value {