mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Merge pull request #25064 from Clarifai/httpheaders-querystring
Automatic merge from submit-queue Preserve query strings in HTTP probes instead of escaping them Fixes a problem reported on Slack by devth. ```release-note * Allow the use of query strings and URI fragments in HTTP probes ``` This might also preserve fragments, for those crazy enough to pass them. I am using url.Parse() on the path in order to get path/query/fragment and also deliberately avoiding the addition of more fields to the API.
This commit is contained in:
commit
a5cd171c2f
@ -208,11 +208,16 @@ func findPortByName(container api.Container, portName string) (int, error) {
|
|||||||
|
|
||||||
// formatURL formats a URL from args. For testability.
|
// formatURL formats a URL from args. For testability.
|
||||||
func formatURL(scheme string, host string, port int, path string) *url.URL {
|
func formatURL(scheme string, host string, port int, path string) *url.URL {
|
||||||
return &url.URL{
|
u, err := url.Parse(path)
|
||||||
Scheme: scheme,
|
// Something is busted with the path, but it's too late to reject it. Pass it along as is.
|
||||||
Host: net.JoinHostPort(host, strconv.Itoa(port)),
|
if err != nil {
|
||||||
Path: path,
|
u = &url.URL{
|
||||||
|
Path: path,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
u.Scheme = scheme
|
||||||
|
u.Host = net.JoinHostPort(host, strconv.Itoa(port))
|
||||||
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
type execInContainer struct {
|
type execInContainer struct {
|
||||||
|
@ -41,6 +41,8 @@ func TestFormatURL(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{"http", "localhost", 93, "", "http://localhost:93"},
|
{"http", "localhost", 93, "", "http://localhost:93"},
|
||||||
{"https", "localhost", 93, "/path", "https://localhost:93/path"},
|
{"https", "localhost", 93, "/path", "https://localhost:93/path"},
|
||||||
|
{"http", "localhost", 93, "?foo", "http://localhost:93?foo"},
|
||||||
|
{"https", "localhost", 93, "/path?bar", "https://localhost:93/path?bar"},
|
||||||
}
|
}
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
url := formatURL(test.scheme, test.host, test.port, test.path)
|
url := formatURL(test.scheme, test.host, test.port, test.path)
|
||||||
|
Loading…
Reference in New Issue
Block a user