From c9dee5d45bd02a07cdcba795aeb5ee4093ea5e06 Mon Sep 17 00:00:00 2001 From: kenichi-mashiyama <274147049+kenichi-mashiyama@users.noreply.github.com> Date: Thu, 20 Aug 2026 18:15:46 +0900 Subject: [PATCH] Add h1-case-adjust-bogus-server option --- apis/proxy/v1alpha1/instance_types.go | 7 +++ apis/proxy/v1alpha1/instance_types_test.go | 43 +++++++++++++++++++ docs/api-reference.md | 1 + .../crds/proxy.haproxy.com_instances.yaml | 4 ++ 4 files changed, 55 insertions(+) diff --git a/apis/proxy/v1alpha1/instance_types.go b/apis/proxy/v1alpha1/instance_types.go index ad58e00..51e6ea0 100644 --- a/apis/proxy/v1alpha1/instance_types.go +++ b/apis/proxy/v1alpha1/instance_types.go @@ -668,6 +668,9 @@ type DefaultsConfiguration struct { // Options configures additional HAProxy defaults options. // +optional Options *DefaultsOptions `json:"options,omitempty"` + // H1CaseAdjustBogusServer enables h1-case-adjust-bogus-server in the defaults section. + // +optional + H1CaseAdjustBogusServer bool `json:"h1CaseAdjustBogusServer,omitempty"` // AdditionalParameters can be used to specify any further configuration statements which are not covered in this section explicitly. // +optional AdditionalParameters string `json:"additionalParameters,omitempty"` @@ -751,6 +754,10 @@ func (d *DefaultsConfiguration) Model() (models.Defaults, error) { defaults.Redispatch = &models.Redispatch{Enabled: ptr.To(enabled)} } + if d.H1CaseAdjustBogusServer { + defaults.H1CaseAdjustBogusServer = models.DefaultsBaseH1CaseAdjustBogusServerEnabled + } + return defaults, defaults.Validate(strfmt.Default) } diff --git a/apis/proxy/v1alpha1/instance_types_test.go b/apis/proxy/v1alpha1/instance_types_test.go index 52a4d68..52be392 100644 --- a/apis/proxy/v1alpha1/instance_types_test.go +++ b/apis/proxy/v1alpha1/instance_types_test.go @@ -112,3 +112,46 @@ func TestDefaultsConfigurationAddToParserWithMaxconn(t *testing.T) { t.Fatalf("expected generated config to contain maxconn 2000, got:\n%s", p.String()) } } + +func TestDefaultsConfiguration_AddToParser_H1CaseAdjustBogusServerEnabled(t *testing.T) { + p, err := parser.New() + if err != nil { + t.Fatalf("failed to create parser: %v", err) + } + + d := &DefaultsConfiguration{ + Mode: "http", + Timeouts: map[string]metav1.Duration{}, + H1CaseAdjustBogusServer: true, + } + + if err := d.AddToParser(p); err != nil { + t.Fatalf("failed to add defaults to parser: %v", err) + } + + cfg := p.String() + if !strings.Contains(cfg, "option h1-case-adjust-bogus-server") { + t.Fatalf("expected h1-case-adjust-bogus-server option in defaults section, got:\n%s", cfg) + } +} + +func TestDefaultsConfiguration_AddToParser_H1CaseAdjustBogusServerDisabledByDefault(t *testing.T) { + p, err := parser.New() + if err != nil { + t.Fatalf("failed to create parser: %v", err) + } + + d := &DefaultsConfiguration{ + Mode: "http", + Timeouts: map[string]metav1.Duration{}, + } + + if err := d.AddToParser(p); err != nil { + t.Fatalf("failed to add defaults to parser: %v", err) + } + + cfg := p.String() + if strings.Contains(cfg, "option h1-case-adjust-bogus-server") { + t.Fatalf("did not expect h1-case-adjust-bogus-server option in defaults section, got:\n%s", cfg) + } +} diff --git a/docs/api-reference.md b/docs/api-reference.md index 3439de5..b70edbb 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1266,6 +1266,7 @@ _Appears in:_ | `retries` _integer_ | Retries sets the maximum number of retries on a connection failure. | | Minimum: 1
Optional: \{\}
| | `logging` _[DefaultsLoggingConfiguration](#defaultsloggingconfiguration)_ | Logging is used to configure default logging for all proxies. | | Optional: \{\}
| | `options` _[DefaultsOptions](#defaultsoptions)_ | Options configures additional HAProxy defaults options. | | Optional: \{\}
| +| `h1CaseAdjustBogusServer` _boolean_ | H1CaseAdjustBogusServer enables h1-case-adjust-bogus-server in the defaults section. | | Optional: \{\}
| | `additionalParameters` _string_ | AdditionalParameters can be used to specify any further configuration statements which are not covered in this section explicitly. | | Optional: \{\}
| diff --git a/helm/haproxy-operator/crds/proxy.haproxy.com_instances.yaml b/helm/haproxy-operator/crds/proxy.haproxy.com_instances.yaml index 03fc303..6523258 100644 --- a/helm/haproxy-operator/crds/proxy.haproxy.com_instances.yaml +++ b/helm/haproxy-operator/crds/proxy.haproxy.com_instances.yaml @@ -156,6 +156,10 @@ spec: in defaults. type: boolean type: object + h1CaseAdjustBogusServer: + description: H1CaseAdjustBogusServer enables h1-case-adjust-bogus-server + in the defaults section. + type: boolean mode: default: http description: Mode can be either 'tcp' or 'http'. In tcp mode