Skip to content
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

[improvement] Implement a generalized ContentDecodingChannel for gzip support #289

Merged
merged 14 commits into from
Feb 17, 2020

Conversation

carterkozak
Copy link
Contributor

Before this PR

Gzip support implemented per-client with risk that the client transparently attempts to use other forms of compression.

After this PR

Standard content-encoding support across all clients.

@carterkozak
Copy link
Contributor Author

This is the change that prompted the Request change (this PR is targeting that branch to reduce the diff)

gzip.write(rawBytes, 3);
gzip.close();
return gzipBytes;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this test, but test all clients wrapped with Channels.create to inherit generalized behavior.

@carterkozak carterkozak force-pushed the ckozak/request_header_sensitivity branch from 42fcb2d to 619ac31 Compare February 6, 2020 17:01
public String toString() {
return "Request{"
+ "headerParamsSize="
+ headerParams.size()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice - no leaking tokens here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a later commit I think I updated this to include header names, not values, for a better debugging experience. Should be in #288

return input;
}

private static final class ContentDecodingResponse implements Response {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming of ContentDecodingChannel and ContentDecodingResponse kinda suggests this might at some point end up handling other kinds of encodings (e.g. brotli)? Is this the intention here or should we name this GzipContentDecodingChannel etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, this class is designed not to set an Accept-Encoding value if a custom value is already set elsewhere so it should be responsible for all conjure-supported response encodings, of which we currently have only one.


@Override
public InputStream body() {
if (body == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this little guy - if the body field is final and assigned in the constructor, how can we end up in the body of this if?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I don't think this conditional is necessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting that nothing about our static analysis tooling complained though!

Copy link
Contributor

@iamdanfox iamdanfox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible to me!

@carterkozak carterkozak force-pushed the ckozak/request_header_sensitivity branch from 619ac31 to ee2f7af Compare February 16, 2020 15:26
This is a break because immutables does not provide a clean way
to use a sorted map without an API change. This breaks ABI, but
retains API in order to give us more options for similar changes
moving forward.
@carterkozak carterkozak force-pushed the ckozak/request_header_sensitivity branch from ee2f7af to aa9dbe6 Compare February 16, 2020 15:42
@carterkozak carterkozak force-pushed the ckozak/ContentDecodingChannel branch from cc1a394 to 60bc5c2 Compare February 16, 2020 15:45
@carterkozak carterkozak force-pushed the ckozak/ContentDecodingChannel branch from 60bc5c2 to e2f68ed Compare February 17, 2020 01:29
@iamdanfox
Copy link
Contributor

Happy to merge when ready this if you are!

@carterkozak
Copy link
Contributor Author

This depends on #288, I'll re-target to develop once that merges

@carterkozak carterkozak changed the base branch from ckozak/request_header_sensitivity to develop February 17, 2020 14:06
@changelog-app
Copy link

changelog-app bot commented Feb 17, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Implement a generalized ContentDecodingChannel for gzip support

Check the box to generate changelog(s)

  • Generate changelog entry

@bulldozer-bot bulldozer-bot bot merged commit 7a93437 into develop Feb 17, 2020
@bulldozer-bot bulldozer-bot bot deleted the ckozak/ContentDecodingChannel branch February 17, 2020 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants