Skip to content

Commit

Permalink
Use non-deprecated Content-Type field in compressor filter (#4475)
Browse files Browse the repository at this point in the history
Follow up to #4403 which
started using a deprecated field

Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
  • Loading branch information
sunjayBhatia authored Apr 18, 2022
1 parent 86ae561 commit 7069f18
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 21 deletions.
22 changes: 13 additions & 9 deletions internal/envoy/v3/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,19 @@ func (b *httpConnectionManagerBuilder) DefaultFilters() *httpConnectionManagerBu
TypeUrl: HTTPFilterGzip,
},
},
ContentType: []string{
// Default content-types https://github.com/envoyproxy/envoy/blob/e74999dbdb12aa4d6b7a5d62d51731ea86bf72be/source/extensions/filters/http/compressor/compressor_filter.cc#L35-L38
"text/html", "text/plain", "text/css", "application/javascript", "application/x-javascript",
"text/javascript", "text/x-javascript", "text/ecmascript", "text/js", "text/jscript",
"text/x-js", "application/ecmascript", "application/x-json", "application/xml",
"application/json", "image/svg+xml", "text/xml", "application/xhtml+xml",
// Additional content-types for grpc-web https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2
"application/grpc-web", "application/grpc-web+proto", "application/grpc-web+json", "application/grpc-web+thrift",
"application/grpc-web-text", "application/grpc-web-text+proto", "application/grpc-web-text+thrift",
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: []string{
// Default content-types https://github.com/envoyproxy/envoy/blob/e74999dbdb12aa4d6b7a5d62d51731ea86bf72be/source/extensions/filters/http/compressor/compressor_filter.cc#L35-L38
"text/html", "text/plain", "text/css", "application/javascript", "application/x-javascript",
"text/javascript", "text/x-javascript", "text/ecmascript", "text/js", "text/jscript",
"text/x-js", "application/ecmascript", "application/x-json", "application/xml",
"application/json", "image/svg+xml", "text/xml", "application/xhtml+xml",
// Additional content-types for grpc-web https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2
"application/grpc-web", "application/grpc-web+proto", "application/grpc-web+json", "application/grpc-web+thrift",
"application/grpc-web-text", "application/grpc-web-text+proto", "application/grpc-web-text+thrift",
},
},
},
}),
},
Expand Down
72 changes: 60 additions & 12 deletions internal/envoy/v3/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -541,7 +545,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -641,7 +649,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -742,7 +754,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -842,7 +858,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -943,7 +963,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -1042,7 +1066,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -1142,7 +1170,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -1243,7 +1275,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -1344,7 +1380,11 @@ func TestHTTPConnectionManager(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
}, {
Expand Down Expand Up @@ -1895,7 +1935,11 @@ func TestAddFilter(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
},
Expand Down Expand Up @@ -1963,7 +2007,11 @@ func TestAddFilter(t *testing.T) {
TypeUrl: HTTPFilterGzip,
},
},
ContentType: compressorContentTypes,
ResponseDirectionConfig: &envoy_compressor_v3.Compressor_ResponseDirectionConfig{
CommonConfig: &envoy_compressor_v3.Compressor_CommonDirectionConfig{
ContentType: compressorContentTypes,
},
},
}),
},
},
Expand Down

0 comments on commit 7069f18

Please sign in to comment.