-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Breaking Change Request] HttpClientResponse.autoUncompress #36971
Comments
Alternatives consideredAn alternative that was considered was just exposing an Benefits
Drawbacks
ConclusionI actually think exposing |
Looping in @Hixie @dgrove @matanlurey for approval. |
Thanks @aadilmaan Note to reviewers: I'm particularly interested in your opinions on the proposal vis-a-vis the alternative described in #36971 (comment) |
"isUncompressed" doesn't describe its semantics very actually. "wasUncompressed" or indeed "wasCompressed" or "wasAutoUncompressed" all seem more accurate. Exposing the client seems like it would essentially be giving code the capability to do more network calls; seems like if the caller wants to do that they should give the client directly themselves. I don't have strong opinions on any of this. Happy for this to go whatever direction you want. |
Actually, thinking about it more, I think just exposing the It keeps the semantics very clear, it unblocks the target use cases, and it alleviates the I'm going to update this issue summary to match. |
Same semantics except for being readonly I assume? |
Yep |
|
LGTM from moi! |
LGTM |
I'd like to see @lrhn 's view on this. I have no objections, but want to hear from him before providing an LGTM. |
The I see three states the response and body can be in:
The user may need to distinguish all three. As uses cases, I'd expect:
Maybe:
Any better ideas? |
Thanks Lasse - I agree with that analysis and the possible solutions. I actually think the With the existing proposal, the caller can get the necessary information by manually checking the TLDR: 👍 to enum HttpClientResponseCompressionState {
/// The body of the HTTP response was received and remains in an uncompressed
/// state.
///
/// In this state, the value of the `Content-Length` HTTP header, if
/// specified (non-negative), should match the number of bytes produced by
/// the response's byte stream.
uncompressed,
/// The body of the HTTP response was originally compressed, but by virtue of
/// the [HttpClient.autoUncompress] configuration option, it has been
/// automatically uncompressed.
///
/// HTTP headers are not modified, so when a response has been uncompressed
/// in this way, the value of the `Content-Length` HTTP header cannot be
/// trusted, as it will contain the compressed content length, whereas the
/// stream of bytes produced by the response will contain uncompressed bytes.
decompressed,
/// The body of the HTTP response contains compressed bytes.
///
/// In this state, the value of the `Content-Length` HTTP header, if
/// specified (non-negative), should match the number of bytes produced by
/// the response's byte stream.
///
/// If the caller wishes to manually uncompress the body of the response,
/// it should consult the value of the `Content-Encoding` HTTP header to see
/// what type of compression has been applied. See
/// https://tools.ietf.org/html/rfc2616#section-14.11 for more information.
compressed,
} |
@matanlurey @dgrove thoughts? |
My biggest concern is that Maybe use I also worry slightly about usability, because enums are not particularly nice to use. if it's not a very common feature (probably not since it hasn't existed before now), then that's probably not an issue. Low-level code gets to have more precision at the cost of less convenience, and this is a low-level feature. |
I agree.
This SGTM. I'll send out the change for review. |
Resolving this, as this has been implemented in aa2ce7c |
Intended change
This proposal is to add a
bool get autoUncompress
getter toHttpClientResponse
, which would have the same semantics asHttpClient.autoUncompress
.Rationale
The use case is when an API method takes an
HttpClientResponse
parameter and needs to know:Content-Length
response header.Expected impact
On callers
This is new API, so callers will be unaffected.
On implementations of the HttpClientResponse interface
Libraries that are implementing the
HttpClientResponse
interface will be broken because they will no longer be implementing the interface. A quick search yielded the following results:Only tests will be affected within these packages, as they are mocking HttpClientResponse:
There's only 1 case I found in a search where API would be broken, and it's an internal Google client, so we'll fix that implementation when this change rolls into Google.
Steps for mitigation
The plan is to release a new non-breaking version bump of
package:http_server
that adds this getter toHttpClientResponse
(without annotating as@override
) so that when the breaking change lands, http_server is already compliant.The text was updated successfully, but these errors were encountered: