Skip to content

Commit

Permalink
Enable configuration of "enable_trailers" protocol setting
Browse files Browse the repository at this point in the history
  • Loading branch information
yabberyabber committed Dec 16, 2022
1 parent 27612b2 commit af1465f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/api/getambassador.io/v3alpha1/crd_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type Features struct {
// Should we enable http/1.0 protocol?
Http10 bool `json:"http10,omitempty"`

// Should we enable http response trailers?
Trailers bool `json:"trailers,omitempty"`

// Should we do IPv4 DNS lookups when contacting services? Defaults to true,
// but can be overridden in a [`Mapping`](/reference/mappings).
Ipv4Dns bool `json:"ipv4_dns,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions python/ambassador/envoy/v3/v3listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ def base_http_config(self) -> Dict[str, Any]:
http_options = base_http_config.setdefault("http_protocol_options", {})
http_options["accept_http_10"] = self.config.ir.ambassador_module.enable_http10

if "enable_trailers" in self.config.ir.ambassador_module:
http_options = base_http_config.setdefault("http_protocol_options", {})
http_options["enable_trailers"] = self.config.ir.ambassador_module.enable_trailers

if "allow_chunked_length" in self.config.ir.ambassador_module:
if self.config.ir.ambassador_module.allow_chunked_length != None:
http_options = base_http_config.setdefault("http_protocol_options", {})
Expand Down
1 change: 1 addition & 0 deletions python/ambassador/ir/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ def features(self) -> Dict[str, Any]:
"use_remote_address",
"x_forwarded_proto_redirect",
"enable_http10",
"enable_trailers",
"add_linkerd_headers",
"use_ambassador_namespace_for_service_resolution",
"proper_case",
Expand Down
2 changes: 2 additions & 0 deletions python/ambassador/ir/irambassador.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class IRAmbassador(IRResource):
"default_labels",
"diagnostics",
"enable_http10",
"enable_trailers",
"enable_ipv4",
"enable_ipv6",
"envoy_log_format",
Expand Down Expand Up @@ -141,6 +142,7 @@ def __init__(
# comment in crd_module.go.
use_proxy_proto=False,
enable_http10=False,
enable_trailers=False,
proper_case=False,
prune_unreachable_routes=True, # default True; can be updated in finalize()
use_remote_address=use_remote_address,
Expand Down
8 changes: 8 additions & 0 deletions python/tests/unit/test_listener_http_protocol_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def test_proper_case_and_enable_http_10():
)


@pytest.mark.compilertest
def test_proper_case_and_enable_http_10():
yaml = module_and_mapping_manifests(["proper_case: true", "enable_trailers: true"], [])
_test_listener_http_protocol_options(
yaml, expectations={"enable_trailers": True, "header_key_format": {"proper_case_words": {}}}
)


@pytest.mark.compilertest
def test_allow_chunked_length_false():
yaml = module_and_mapping_manifests(["allow_chunked_length: false"], [])
Expand Down

0 comments on commit af1465f

Please sign in to comment.