compressor: add support for compressing request payloads (#14302)
The compressor filter adds support for compressing request payloads. Its configuration is unified with the decompressor filter with two new fields for different directions - requests and responses. The latter deprecates the old response-specific fields and, if used, roots the response-specific stats in <stat_prefix>.compressor.<compressor_library.name>.<compressor_library_stat_prefix>.response.* instead of <stat_prefix>.compressor.<compressor_library.name>.<compressor_library_stat_prefix>.*. Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@intel.com> Mirrored from https://github.com/envoyproxy/envoy @ b0fedbe914092124dbffb0e9d3e8ea8928f74bb9pull/623/head
parent
4753762ed7
commit
f014fc0ab5
5 changed files with 282 additions and 7 deletions
@ -0,0 +1,13 @@ |
||||
# 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 = [ |
||||
"//envoy/config/core/v4alpha:pkg", |
||||
"//envoy/extensions/filters/http/compressor/v3:pkg", |
||||
"@com_github_cncf_udpa//udpa/annotations:pkg", |
||||
], |
||||
) |
@ -0,0 +1,106 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package envoy.extensions.filters.http.compressor.v4alpha; |
||||
|
||||
import "envoy/config/core/v4alpha/base.proto"; |
||||
import "envoy/config/core/v4alpha/extension.proto"; |
||||
|
||||
import "google/protobuf/any.proto"; |
||||
import "google/protobuf/wrappers.proto"; |
||||
|
||||
import "udpa/annotations/status.proto"; |
||||
import "udpa/annotations/versioning.proto"; |
||||
import "validate/validate.proto"; |
||||
|
||||
option java_package = "io.envoyproxy.envoy.extensions.filters.http.compressor.v4alpha"; |
||||
option java_outer_classname = "CompressorProto"; |
||||
option java_multiple_files = true; |
||||
option (udpa.annotations.file_status).package_version_status = NEXT_MAJOR_VERSION_CANDIDATE; |
||||
|
||||
// [#protodoc-title: Compressor] |
||||
// Compressor :ref:`configuration overview <config_http_filters_compressor>`. |
||||
// [#extension: envoy.filters.http.compressor] |
||||
|
||||
// [#next-free-field: 9] |
||||
message Compressor { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.compressor.v3.Compressor"; |
||||
|
||||
message CommonDirectionConfig { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.compressor.v3.Compressor.CommonDirectionConfig"; |
||||
|
||||
// Runtime flag that controls whether compression is enabled or not for the direction this |
||||
// common config is put in. If set to false, the filter will operate as a pass-through filter |
||||
// in the chosen direction. If the field is omitted, the filter will be enabled. |
||||
config.core.v4alpha.RuntimeFeatureFlag enabled = 1; |
||||
|
||||
// Minimum value of Content-Length header of request or response messages (depending on the direction |
||||
// this common config is put in), in bytes, which will trigger compression. The default value is 30. |
||||
google.protobuf.UInt32Value min_content_length = 2; |
||||
|
||||
// Set of strings that allows specifying which mime-types yield compression; e.g., |
||||
// application/json, text/html, etc. When this field is not defined, compression will be applied |
||||
// to the following mime-types: "application/javascript", "application/json", |
||||
// "application/xhtml+xml", "image/svg+xml", "text/css", "text/html", "text/plain", "text/xml" |
||||
// and their synonyms. |
||||
repeated string content_type = 3; |
||||
} |
||||
|
||||
// Configuration for filter behavior on the request direction. |
||||
message RequestDirectionConfig { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.compressor.v3.Compressor.RequestDirectionConfig"; |
||||
|
||||
CommonDirectionConfig common_config = 1; |
||||
} |
||||
|
||||
// Configuration for filter behavior on the response direction. |
||||
message ResponseDirectionConfig { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.compressor.v3.Compressor.ResponseDirectionConfig"; |
||||
|
||||
CommonDirectionConfig common_config = 1; |
||||
|
||||
// If true, disables compression when the response contains an etag header. When it is false, the |
||||
// filter will preserve weak etags and remove the ones that require strong validation. |
||||
bool disable_on_etag_header = 2; |
||||
|
||||
// If true, removes accept-encoding from the request headers before dispatching it to the upstream |
||||
// so that responses do not get compressed before reaching the filter. |
||||
// |
||||
// .. attention:: |
||||
// |
||||
// To avoid interfering with other compression filters in the same chain use this option in |
||||
// the filter closest to the upstream. |
||||
bool remove_accept_encoding_header = 3; |
||||
} |
||||
|
||||
reserved 1, 2, 3, 4, 5; |
||||
|
||||
reserved "content_length", "content_type", "disable_on_etag_header", |
||||
"remove_accept_encoding_header", "runtime_enabled"; |
||||
|
||||
// A compressor library to use for compression. Currently only |
||||
// :ref:`envoy.compression.gzip.compressor<envoy_api_msg_extensions.compression.gzip.compressor.v3.Gzip>` |
||||
// is included in Envoy. |
||||
// This field is ignored if used in the context of the gzip http-filter, but is mandatory otherwise. |
||||
config.core.v4alpha.TypedExtensionConfig compressor_library = 6; |
||||
|
||||
// Configuration for request compression. Compression is disabled by default if left empty. |
||||
RequestDirectionConfig request_direction_config = 7; |
||||
|
||||
// Configuration for response compression. Compression is enabled by default if left empty. |
||||
// |
||||
// .. attention:: |
||||
// |
||||
// If the field is not empty then the duplicate deprecated fields of the `Compressor` message, |
||||
// such as `content_length`, `content_type`, `disable_on_etag_header`, |
||||
// `remove_accept_encoding_header` and `runtime_enabled`, are ignored. |
||||
// |
||||
// Also all the statistics related to response compression will be rooted in |
||||
// `<stat_prefix>.compressor.<compressor_library.name>.<compressor_library_stat_prefix>.response.*` |
||||
// instead of |
||||
// `<stat_prefix>.compressor.<compressor_library.name>.<compressor_library_stat_prefix>.*`. |
||||
ResponseDirectionConfig response_direction_config = 8; |
||||
} |
@ -0,0 +1,13 @@ |
||||
# 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 = [ |
||||
"//envoy/extensions/filters/http/compressor/v4alpha:pkg", |
||||
"//envoy/extensions/filters/http/gzip/v3:pkg", |
||||
"@com_github_cncf_udpa//udpa/annotations:pkg", |
||||
], |
||||
) |
@ -0,0 +1,84 @@ |
||||
syntax = "proto3"; |
||||
|
||||
package envoy.extensions.filters.http.gzip.v4alpha; |
||||
|
||||
import "envoy/extensions/filters/http/compressor/v4alpha/compressor.proto"; |
||||
|
||||
import "google/protobuf/wrappers.proto"; |
||||
|
||||
import "udpa/annotations/status.proto"; |
||||
import "udpa/annotations/versioning.proto"; |
||||
import "validate/validate.proto"; |
||||
|
||||
option java_package = "io.envoyproxy.envoy.extensions.filters.http.gzip.v4alpha"; |
||||
option java_outer_classname = "GzipProto"; |
||||
option java_multiple_files = true; |
||||
option (udpa.annotations.file_status).package_version_status = NEXT_MAJOR_VERSION_CANDIDATE; |
||||
|
||||
// [#protodoc-title: Gzip] |
||||
// Gzip :ref:`configuration overview <config_http_filters_gzip>`. |
||||
// [#extension: envoy.filters.http.gzip] |
||||
|
||||
// [#next-free-field: 12] |
||||
message Gzip { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.gzip.v3.Gzip"; |
||||
|
||||
enum CompressionStrategy { |
||||
DEFAULT = 0; |
||||
FILTERED = 1; |
||||
HUFFMAN = 2; |
||||
RLE = 3; |
||||
} |
||||
|
||||
message CompressionLevel { |
||||
option (udpa.annotations.versioning).previous_message_type = |
||||
"envoy.extensions.filters.http.gzip.v3.Gzip.CompressionLevel"; |
||||
|
||||
enum Enum { |
||||
DEFAULT = 0; |
||||
BEST = 1; |
||||
SPEED = 2; |
||||
} |
||||
} |
||||
|
||||
reserved 2, 6, 7, 8; |
||||
|
||||
reserved "content_length", "content_type", "disable_on_etag_header", |
||||
"remove_accept_encoding_header"; |
||||
|
||||
// Value from 1 to 9 that controls the amount of internal memory used by zlib. Higher values |
||||
// use more memory, but are faster and produce better compression results. The default value is 5. |
||||
google.protobuf.UInt32Value memory_level = 1 [(validate.rules).uint32 = {lte: 9 gte: 1}]; |
||||
|
||||
// A value used for selecting the zlib compression level. This setting will affect speed and |
||||
// amount of compression applied to the content. "BEST" provides higher compression at the cost of |
||||
// higher latency, "SPEED" provides lower compression with minimum impact on response time. |
||||
// "DEFAULT" provides an optimal result between speed and compression. This field will be set to |
||||
// "DEFAULT" if not specified. |
||||
CompressionLevel.Enum compression_level = 3 [(validate.rules).enum = {defined_only: true}]; |
||||
|
||||
// A value used for selecting the zlib compression strategy which is directly related to the |
||||
// characteristics of the content. Most of the time "DEFAULT" will be the best choice, though |
||||
// there are situations which changing this parameter might produce better results. For example, |
||||
// run-length encoding (RLE) is typically used when the content is known for having sequences |
||||
// which same data occurs many consecutive times. For more information about each strategy, please |
||||
// refer to zlib manual. |
||||
CompressionStrategy compression_strategy = 4 [(validate.rules).enum = {defined_only: true}]; |
||||
|
||||
// Value from 9 to 15 that represents the base two logarithmic of the compressor's window size. |
||||
// Larger window results in better compression at the expense of memory usage. The default is 12 |
||||
// which will produce a 4096 bytes window. For more details about this parameter, please refer to |
||||
// zlib manual > deflateInit2. |
||||
google.protobuf.UInt32Value window_bits = 9 [(validate.rules).uint32 = {lte: 15 gte: 9}]; |
||||
|
||||
// Set of configuration parameters common for all compression filters. If this field is set then |
||||
// the fields `content_length`, `content_type`, `disable_on_etag_header` and |
||||
// `remove_accept_encoding_header` are ignored. |
||||
compressor.v4alpha.Compressor compressor = 10; |
||||
|
||||
// Value for Zlib's next output buffer. If not set, defaults to 4096. |
||||
// See https://www.zlib.net/manual.html for more details. Also see |
||||
// https://github.com/envoyproxy/envoy/issues/8448 for context on this filter's performance. |
||||
google.protobuf.UInt32Value chunk_size = 11 [(validate.rules).uint32 = {lte: 65536 gte: 4096}]; |
||||
} |
Loading…
Reference in new issue