Commit 55b1ae85 authored by Ed Robinson's avatar Ed Robinson

Allow setting the Host header in a httpGet probe

Fixes #24288
parent 6320e41b
......@@ -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.
......
......@@ -86,6 +86,20 @@ func TestHTTPProbeChecker(t *testing.T) {
},
},
{
// 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,
probe.Failure,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment