Skip to content

Commit

Permalink
HTTPProxy: support case insensitive header matching (#5567)
Browse files Browse the repository at this point in the history
Adds an option for header matches to
be case-insensitive, similar to the equivalent
functionality for query parameter matching.

Signed-off-by: Sotiris Nanopoulos <sotiris.nanopoulos@reddit.com>
  • Loading branch information
davinci26 authored Jul 24, 2023
1 parent 81a612f commit f6c112e
Show file tree
Hide file tree
Showing 17 changed files with 570 additions and 93 deletions.
10 changes: 8 additions & 2 deletions apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ type MatchCondition struct {
}

// HeaderMatchCondition specifies how to conditionally match against HTTP
// headers. The Name field is required, but only one of the remaining
// fields should be be provided.
// headers. The Name field is required, only one of Present, NotPresent,
// Contains, NotContains, Exact, NotExact and Regex can be set.
// IgnoreCase has no effect for Regex.
type HeaderMatchCondition struct {
// Name is the name of the header to match against. Name is required.
// Header names are case insensitive.
Expand Down Expand Up @@ -118,6 +119,11 @@ type HeaderMatchCondition struct {
// +optional
NotContains string `json:"notcontains,omitempty"`

// IgnoreCase specifies that string matching should be case insensitive.
// Note that this has no effect on the Regex parameter.
// +optional
IgnoreCase bool `json:"ignoreCase,omitempty"`

// Exact specifies a string that the header value must be equal to.
// +optional
Exact string `json:"exact,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions changelogs/unreleased/5567-davinci26-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Adds support for case-insensitive header matching

Adds support for `IgnoreCase` in route header matching condition. This brings parity to matching capabilities of query param.
62 changes: 53 additions & 9 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,11 @@ spec:
items:
description: HeaderMatchCondition specifies
how to conditionally match against HTTP
headers. The Name field is required, but
only one of the remaining fields should
be be provided.
headers. The Name field is required, only
one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect for
Regex.
properties:
contains:
description: Contains specifies a substring
Expand All @@ -738,6 +740,12 @@ spec:
that the header value must be equal
to.
type: string
ignoreCase:
description: IgnoreCase specifies that
string matching should be case insensitive.
Note that this has no effect on the
Regex parameter.
type: boolean
name:
description: Name is the name of the
header to match against. Name is required.
Expand Down Expand Up @@ -4111,8 +4119,10 @@ spec:
description: HeaderMatchCondition specifies
how to conditionally match against
HTTP headers. The Name field is required,
but only one of the remaining fields
should be be provided.
only one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect
for Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -4124,6 +4134,12 @@ spec:
that the header value must be
equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should be
case insensitive. Note that this
has no effect on the Regex parameter.
type: boolean
name:
description: Name is the name of
the header to match against. Name
Expand Down Expand Up @@ -4926,6 +4942,11 @@ spec:
description: Exact specifies a string that the header
value must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies that string matching
should be case insensitive. Note that this has no
effect on the Regex parameter.
type: boolean
name:
description: Name is the name of the header to match
against. Name is required. Header names are case
Expand Down Expand Up @@ -5083,6 +5104,11 @@ spec:
description: Exact specifies a string that the header
value must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies that string matching
should be case insensitive. Note that this has no
effect on the Regex parameter.
type: boolean
name:
description: Name is the name of the header to match
against. Name is required. Header names are case
Expand Down Expand Up @@ -5641,8 +5667,11 @@ spec:
description: HeaderMatchCondition
specifies how to conditionally match
against HTTP headers. The Name field
is required, but only one of the
remaining fields should be be provided.
is required, only one of Present,
NotPresent, Contains, NotContains,
Exact, NotExact and Regex can be
set. IgnoreCase has no effect for
Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -5654,6 +5683,13 @@ spec:
string that the header value
must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should
be case insensitive. Note that
this has no effect on the Regex
parameter.
type: boolean
name:
description: Name is the name
of the header to match against.
Expand Down Expand Up @@ -7001,8 +7037,10 @@ spec:
description: HeaderMatchCondition specifies
how to conditionally match against
HTTP headers. The Name field is required,
but only one of the remaining fields
should be be provided.
only one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect
for Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -7014,6 +7052,12 @@ spec:
that the header value must be
equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should be
case insensitive. Note that this
has no effect on the Regex parameter.
type: boolean
name:
description: Name is the name of
the header to match against. Name
Expand Down
62 changes: 53 additions & 9 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,11 @@ spec:
items:
description: HeaderMatchCondition specifies
how to conditionally match against HTTP
headers. The Name field is required, but
only one of the remaining fields should
be be provided.
headers. The Name field is required, only
one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect for
Regex.
properties:
contains:
description: Contains specifies a substring
Expand All @@ -951,6 +953,12 @@ spec:
that the header value must be equal
to.
type: string
ignoreCase:
description: IgnoreCase specifies that
string matching should be case insensitive.
Note that this has no effect on the
Regex parameter.
type: boolean
name:
description: Name is the name of the
header to match against. Name is required.
Expand Down Expand Up @@ -4324,8 +4332,10 @@ spec:
description: HeaderMatchCondition specifies
how to conditionally match against
HTTP headers. The Name field is required,
but only one of the remaining fields
should be be provided.
only one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect
for Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -4337,6 +4347,12 @@ spec:
that the header value must be
equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should be
case insensitive. Note that this
has no effect on the Regex parameter.
type: boolean
name:
description: Name is the name of
the header to match against. Name
Expand Down Expand Up @@ -5139,6 +5155,11 @@ spec:
description: Exact specifies a string that the header
value must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies that string matching
should be case insensitive. Note that this has no
effect on the Regex parameter.
type: boolean
name:
description: Name is the name of the header to match
against. Name is required. Header names are case
Expand Down Expand Up @@ -5296,6 +5317,11 @@ spec:
description: Exact specifies a string that the header
value must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies that string matching
should be case insensitive. Note that this has no
effect on the Regex parameter.
type: boolean
name:
description: Name is the name of the header to match
against. Name is required. Header names are case
Expand Down Expand Up @@ -5854,8 +5880,11 @@ spec:
description: HeaderMatchCondition
specifies how to conditionally match
against HTTP headers. The Name field
is required, but only one of the
remaining fields should be be provided.
is required, only one of Present,
NotPresent, Contains, NotContains,
Exact, NotExact and Regex can be
set. IgnoreCase has no effect for
Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -5867,6 +5896,13 @@ spec:
string that the header value
must be equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should
be case insensitive. Note that
this has no effect on the Regex
parameter.
type: boolean
name:
description: Name is the name
of the header to match against.
Expand Down Expand Up @@ -7214,8 +7250,10 @@ spec:
description: HeaderMatchCondition specifies
how to conditionally match against
HTTP headers. The Name field is required,
but only one of the remaining fields
should be be provided.
only one of Present, NotPresent, Contains,
NotContains, Exact, NotExact and Regex
can be set. IgnoreCase has no effect
for Regex.
properties:
contains:
description: Contains specifies
Expand All @@ -7227,6 +7265,12 @@ spec:
that the header value must be
equal to.
type: string
ignoreCase:
description: IgnoreCase specifies
that string matching should be
case insensitive. Note that this
has no effect on the Regex parameter.
type: boolean
name:
description: Name is the name of
the header to match against. Name
Expand Down
Loading

0 comments on commit f6c112e

Please sign in to comment.