-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: add HTTP/1.1 case preservation
1) Add new stateful header formatter extension point 2) Add preserve case formatter extension Fixes #14363 Signed-off-by: Matt Klein <[email protected]>
- Loading branch information
1 parent
531c6ac
commit f8b938c
Showing
47 changed files
with
700 additions
and
135 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
api/envoy/extensions/http/header_formatters/preserve_case/v3/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. | ||
|
||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
api_proto_package( | ||
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"], | ||
) |
19 changes: 19 additions & 0 deletions
19
api/envoy/extensions/http/header_formatters/preserve_case/v3/preserve_case.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.extensions.http.header_formatters.preserve_case.v3; | ||
|
||
import "udpa/annotations/status.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.extensions.http.header_formatters.preserve_case.v3"; | ||
option java_outer_classname = "PreserveCaseProto"; | ||
option java_multiple_files = true; | ||
option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
||
// [#protodoc-title: Preserve case header formatter] | ||
// [#extension: envoy.http.header_formatters.preserve_case] | ||
|
||
// Configuration for the preserve case header formatter. | ||
// See the :ref:`header casing <config_http_conn_man_header_casing>` configuration guide for more | ||
// information. | ||
message PreserveCaseFormatterConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ Extensions | |
watchdog/watchdog | ||
descriptors/descriptors | ||
request_id/request_id | ||
http/header_formatters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HTTP header formatters | ||
====================== | ||
|
||
.. toctree:: | ||
:glob: | ||
:maxdepth: 2 | ||
|
||
../../extensions/http/header_formatters/*/v3/* |
50 changes: 50 additions & 0 deletions
50
docs/root/configuration/http/http_conn_man/_include/preserve-case.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
static_resources: | ||
listeners: | ||
- address: | ||
socket_address: | ||
address: 0.0.0.0 | ||
port_value: 443 | ||
filter_chains: | ||
- filters: | ||
- name: envoy.filters.network.http_connection_manager | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | ||
stat_prefix: ingress_http | ||
http_protocol_options: | ||
header_key_format: | ||
stateful_formatter: | ||
name: preserve_case | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig | ||
http_filters: | ||
- name: envoy.filters.http.router | ||
route_config: | ||
virtual_hosts: | ||
- name: default | ||
domains: ["*"] | ||
routes: | ||
- match: { prefix: "/" } | ||
route: | ||
cluster: service_foo | ||
clusters: | ||
- name: service_foo | ||
connect_timeout: 15s | ||
typed_extension_protocol_options: | ||
envoy.extensions.upstreams.http.v3.HttpProtocolOptions: | ||
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions | ||
explicit_http_config: | ||
http_protocol_options: | ||
header_key_format: | ||
stateful_formatter: | ||
name: preserve_case | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig | ||
load_assignment: | ||
cluster_name: some_service | ||
endpoints: | ||
- lb_endpoints: | ||
- endpoint: | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 8080 |
44 changes: 38 additions & 6 deletions
44
docs/root/configuration/http/http_conn_man/header_casing.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,46 @@ | ||
.. _config_http_conn_man_header_casing: | ||
|
||
HTTP/1.1 Header Casing | ||
====================== | ||
|
||
When handling HTTP/1.1, Envoy will normalize the header keys to be all lowercase. While this is | ||
compliant with the HTTP/1.1 spec, in practice this can result in issues when migrating | ||
existing systems that might rely on specific header casing. | ||
|
||
To support these use cases, Envoy allows configuring a formatting scheme for the headers, which | ||
will have Envoy transform the header keys during serialization. To configure this formatting on | ||
response headers, specify the format in the :ref:`http_protocol_options <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.http_protocol_options>`. | ||
To configure this for upstream request headers, specify the formatting in :ref:`http_protocol_options <envoy_v3_api_msg_extensions.upstreams.http.v3.HttpProtocolOptions>` in the Cluster's :ref:`extension_protocol_options<envoy_v3_api_field_config.cluster.v3.Cluster.typed_extension_protocol_options>`. | ||
To support these use cases, Envoy allows :ref:`configuring a formatting scheme for the headers | ||
<envoy_v3_api_field_config.core.v3.Http1ProtocolOptions.header_key_format>`, which will have Envoy | ||
transform the header keys during serialization. | ||
|
||
To configure this formatting on response headers, specify the format in the | ||
:ref:`http_protocol_options | ||
<envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.http_protocol_options>`. | ||
To configure this for upstream request headers, specify the formatting in | ||
:ref:`http_protocol_options <envoy_v3_api_msg_extensions.upstreams.http.v3.HttpProtocolOptions>` in | ||
the cluster's | ||
:ref:`extension_protocol_options<envoy_v3_api_field_config.cluster.v3.Cluster.typed_extension_protocol_options>`. | ||
|
||
Currently Envoy supports two different types of header key formatters: | ||
|
||
Stateless formatters | ||
-------------------- | ||
|
||
Stateless formatters are run on encoding and do not depend on any previous knowledge of the headers. | ||
An example of this type of formatter is the :ref:`proper case words | ||
<envoy_v3_api_field_config.core.v3.Http1ProtocolOptions.HeaderKeyFormat.proper_case_words>` | ||
formatter. These formatters are useful when converting to non-HTTP/1 to HTTP/1 or when stateful | ||
formatting is not desired due to increases memory requirements. | ||
|
||
Stateful formatters | ||
------------------- | ||
|
||
Stateful formatters are instantiated on decoding, passed every decoded header, attached to the | ||
header map, and then available during encoding to format the headers prior to writing. Thus, they | ||
traverse the entire proxy stack. An example of this type of formatter is the :ref:`preserve case | ||
formatter | ||
<envoy_v3_api_msg_extensions.http.header_formatters.preserve_case.v3.PreserveCaseFormatterConfig>` | ||
configured via the :ref:`stateful_formatter | ||
<envoy_v3_api_field_config.core.v3.Http1ProtocolOptions.HeaderKeyFormat.stateful_formatter>` field. | ||
The following is an example configuration which will preserve HTTP/1 header case across the proxy. | ||
|
||
See :ref:`below <faq_configuration_timeouts_transport_socket>` for other connection timeouts. | ||
on the :ref:`Cluster <envoy_v3_api_field_config.cluster.v3.Cluster.http_protocol_options>`. FIXME | ||
.. literalinclude:: _include/preserve-case.yaml | ||
:language: yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
generated_api_shadow/envoy/config/core/v4alpha/protocol.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
generated_api_shadow/envoy/extensions/http/header_formatters/preserve_case/v3/BUILD
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...d_api_shadow/envoy/extensions/http/header_formatters/preserve_case/v3/preserve_case.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.