-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add config setting to disable gzip compression #1627 #1628
base: main
Are you sure you want to change the base?
Conversation
markdingram
commented
Nov 5, 2024
- rounds out all of the https://kubernetes.io/docs/reference/config-api/kubeconfig.v1/#Cluster options
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1628 +/- ##
=======================================
+ Coverage 75.3% 75.5% +0.3%
=======================================
Files 82 82
Lines 7344 7376 +32
=======================================
+ Hits 5528 5567 +39
+ Misses 1816 1809 -7
|
3be2b14
to
06b4b0e
Compare
.layer(tower_http::decompression::DecompressionLayer::new()) | ||
.layer( | ||
tower_http::decompression::DecompressionLayer::new() | ||
.no_br() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intentionally disable anything but GZIP compression -
reading kubernetes/kubernetes#112296 show there isn't like to be any other option in Kube for a while, but these flags could easily be refitted when/if Kube gains alternatives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. think this is sensible also.
@@ -158,7 +158,13 @@ where | |||
#[cfg(feature = "gzip")] | |||
let stack = ServiceBuilder::new() | |||
.layer(stack) | |||
.layer(tower_http::decompression::DecompressionLayer::new()) | |||
.layer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to wrap the whole layer in an "option_layer" block ran head first into a load of compile issues - fortunately the Compression Layer supports enabling/disabling through configuration hence that path was chosen
Remaining work on this PR is to add a test to check the Accept-Encoding header when the disabled flag is set |
62c7009
to
71598b8
Compare
- rounds out all of the https://kubernetes.io/docs/reference/config-api/kubeconfig.v1/#Cluster options Signed-off-by: Mark Ingram <[email protected]>
71598b8
to
22dfd0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you very much. Sensible porting of upstream behavior and sensible defaulting.
we've not historically been great at testing this area of the code base and this is a very nice way of doing it
// confirm gzip echoed back with default config | ||
let config = Config { ..Config::new(uri) }; | ||
let client = make_generic_builder(HttpConnector::new(), config.clone())?.build(); | ||
let response = client.request_text(http::Request::default()).await?; | ||
assert_eq!(&response, "gzip"); | ||
|
||
// now disable and check empty string echoed back | ||
let config = Config { | ||
disable_compression: true, | ||
..config | ||
}; | ||
let client = make_generic_builder(HttpConnector::new(), config)?.build(); | ||
let response = client.request_text(http::Request::default()).await?; | ||
assert_eq!(&response, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow great test. 👍