Skip to content

Commit

Permalink
Allow setting the Host header in a httpGet probe
Browse files Browse the repository at this point in the history
Fixes #24288
  • Loading branch information
errm committed Apr 15, 2016
1 parent 6320e41 commit 55b1ae8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

1 comment on commit 55b1ae8

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 21484 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 276 Build time: 00:08:00

Please sign in to comment.