mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #24292 from errm/fix-http-get-host-header
Automatic merge from submit-queue Allow setting the Host header in a httpGet probe
This commit is contained in:
commit
e8bd081ee2
@ -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.
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user