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

client: set grpc-accept-encoding header based on outgoing compressor #3139

Merged
merged 1 commit into from
Nov 18, 2019
Merged

client: set grpc-accept-encoding header based on outgoing compressor #3139

merged 1 commit into from
Nov 18, 2019

Conversation

jiacai2050
Copy link
Contributor

@jiacai2050 jiacai2050 commented Nov 4, 2019

Apply this PR, the server will response with grpc-encoding whatever the client set. test via wireshark.

update #2786

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 4, 2019

CLA Check
The committers are authorized under a signed CLA.

@dfawley dfawley self-requested a review November 7, 2019 21:17
@dfawley
Copy link
Member

dfawley commented Nov 7, 2019

@jiacai2050 this is only a partial fix of #2786. It only addresses the client-side, and only on the outbound path (i.e. it does not respect the server's accept-encoding headers). Also it only presents the compression method used when sending the RPC. The client may support other codecs, however: everything registered with the encoding package.

Are you seeing problems when this header is not set (before this change)?

@dfawley dfawley assigned jiacai2050 and unassigned dfawley Nov 7, 2019
@jiacai2050
Copy link
Contributor Author

It only addresses the client-side, and only on the outbound path (i.e. it does not respect the server's accept-encoding headers)

Yes, but this is the original logic. How can we get the accept-encoding sent by server's last response?

The client may support other codecs, however: everything registered with the encoding package.

Yes, but it seems there is no way to get all codecs since registeredCodecs is package-private.

Are you seeing problems when this header is not set (before this change)?

If this header isn't set, then the server will never send compressed response.

@dfawley
Copy link
Member

dfawley commented Nov 8, 2019

Yes, but this is the original logic. How can we get the accept-encoding sent by server's last response?

This would have to be a new feature.

Yes, but it seems there is no way to get all codecs since registeredCodecs is package-private.

Correct. We could make this available to grpc's transport via the internal package to keep it unexported.

If this header isn't set, then the server will never send compressed response.

That makes sense - you mean for interop with other grpc languages, right? I think the grpc-go server is missing the implementation to not send compressed if the client doesn't set this header.

@jiacai2050
Copy link
Contributor Author

jiacai2050 commented Nov 9, 2019

you mean for interop with other grpc languages, right?

Yes, the server is built in rust.

After digging into how grpc-go client receive msg, I find it use compression set for outbound msg to decompress response, Is there anything I'm missing?

d, size, err = decompress(compressor, d, maxReceiveMessageSize)
// should be
d, size, err = decompress(getCompressor(s.RecvCompress()), d, maxReceiveMessageSize)

@menghanl menghanl changed the title add grpc-accept-encoding. fix #2786 add grpc-accept-encoding Nov 14, 2019
@dfawley dfawley changed the title add grpc-accept-encoding client: set grpc-accept-encoding header based on outgoing compressor used Nov 18, 2019
@dfawley
Copy link
Member

dfawley commented Nov 18, 2019

After digging into how grpc-go client receive msg, I find it use compression set for outbound msg to decompress response, Is there anything I'm missing?

I believe the code you found is fine. We set the decompressor based on the stream's header here:

grpc-go/stream.go

Lines 872 to 876 in 347a6b4

if a.dc == nil || a.dc.Type() != ct {
// No configured decompressor, or it does not match the incoming
// message encoding; attempt to find a registered compressor that does.
a.dc = nil
a.decomp = encoding.GetCompressor(ct)

I will merge this PR as a short-term workaround for this issue, but we should not close #2786 yet as there are several more things needed.

@dfawley dfawley added this to the 1.26 Release milestone Nov 18, 2019
@dfawley dfawley changed the title client: set grpc-accept-encoding header based on outgoing compressor used client: set grpc-accept-encoding header based on outgoing compressor Nov 18, 2019
@dfawley dfawley merged commit 967379b into grpc:master Nov 18, 2019
RealBar pushed a commit to RealBar/grpc-go that referenced this pull request Nov 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants