Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the Host header in a httpGet probe #24292

Merged
merged 1 commit into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/probe/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions pkg/probe/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down