use case-insensitive header keys for http probes

This commit is contained in:
dddddai 2023-04-12 15:39:55 +08:00
parent ad18954259
commit 10a8ec5b2c
11 changed files with 24 additions and 10 deletions

View File

@ -6192,7 +6192,7 @@
"description": "HTTPHeader describes a custom header to be used in HTTP probes",
"properties": {
"name": {
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {

View File

@ -2632,7 +2632,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {

View File

@ -2568,7 +2568,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {

View File

@ -1859,7 +1859,7 @@
"properties": {
"name": {
"default": "",
"description": "The header field name",
"description": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"type": "string"
},
"value": {

View File

@ -2037,7 +2037,8 @@ type SecretEnvSource struct {
// HTTPHeader describes a custom header to be used in HTTP probes
type HTTPHeader struct {
// The header field name
// The header field name.
// This will be canonicalized upon output, so case-variant names will be understood as the same header.
Name string
// The header field value
Value string

View File

@ -19979,7 +19979,7 @@ func schema_k8sio_api_core_v1_HTTPHeader(ref common.ReferenceCallback) common.Op
Properties: map[string]spec.Schema{
"name": {
SchemaProps: spec.SchemaProps{
Description: "The header field name",
Description: "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
Default: "",
Type: []string{"string"},
Format: "",

View File

@ -113,7 +113,7 @@ func formatURL(scheme string, host string, port int, path string) *url.URL {
func v1HeaderToHTTPHeader(headerList []v1.HTTPHeader) http.Header {
headers := make(http.Header)
for _, header := range headerList {
headers[header.Name] = append(headers[header.Name], header.Value)
headers.Add(header.Name, header.Value)
}
return headers
}

View File

@ -64,6 +64,17 @@ func Test_v1HeaderToHTTPHeader(t *testing.T) {
"Accept-Ranges": {"bytes"},
},
},
{
name: "case insensitive",
headerList: []v1.HTTPHeader{
{Name: "HOST", Value: "example.com"},
{Name: "FOO-bAR", Value: "value"},
},
want: http.Header{
"Host": {"example.com"},
"Foo-Bar": {"value"},
},
},
{
name: "empty input",
headerList: []v1.HTTPHeader{},

View File

@ -1853,7 +1853,8 @@ message HTTPGetAction {
// HTTPHeader describes a custom header to be used in HTTP probes
message HTTPHeader {
// The header field name
// The header field name.
// This will be canonicalized upon output, so case-variant names will be understood as the same header.
optional string name = 1;
// The header field value

View File

@ -2137,7 +2137,8 @@ type SecretEnvSource struct {
// HTTPHeader describes a custom header to be used in HTTP probes
type HTTPHeader struct {
// The header field name
// The header field name.
// This will be canonicalized upon output, so case-variant names will be understood as the same header.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// The header field value
Value string `json:"value" protobuf:"bytes,2,opt,name=value"`

View File

@ -832,7 +832,7 @@ func (HTTPGetAction) SwaggerDoc() map[string]string {
var map_HTTPHeader = map[string]string{
"": "HTTPHeader describes a custom header to be used in HTTP probes",
"name": "The header field name",
"name": "The header field name. This will be canonicalized upon output, so case-variant names will be understood as the same header.",
"value": "The header field value",
}