Allow setting the Host header in a httpGet probe

Fixes #24288
pull/6/head
Ed Robinson 2016-04-14 23:48:32 +01:00
parent 6320e41b4f
commit 55b1ae857c
2 changed files with 17 additions and 0 deletions

View File

@ -64,6 +64,9 @@ func DoHTTPProbe(url *url.URL, headers http.Header, client HTTPGetInterface) (pr
return probe.Failure, err.Error(), nil
}
req.Header = headers
if headers.Get("Host") != "" {
req.Host = headers.Get("Host")
}
res, err := client.Do(req)
if err != nil {
// Convert errors into failures to catch timeouts.

View File

@ -85,6 +85,20 @@ func TestHTTPProbeChecker(t *testing.T) {
"X-Muffins-Or-Cupcakes: muffins",
},
},
{
// Echo handler that returns the contents of Host in the body
func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte(r.Host))
},
http.Header{
"Host": {"muffins.cupcakes.org"},
},
probe.Success,
[]string{
"muffins.cupcakes.org",
},
},
{
handleReq(FailureCode, "fail body"),
nil,