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

Remove an invalid content-length in a gRPC streaming response. #4460

Merged
merged 2 commits into from
Oct 5, 2022

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Oct 4, 2022

Motivation:

If a wrong content-length is set, the request/stream is reset by the Netty HTTP/2 codec. Most gRPC server call implmentations do not set a content-length to response headers. But some gRPC implementations such as Monix-gRPC send a content-length which was in the request content-length. I guess the runtime uses the incoming Metadata as the response Metadata itself.
Related: monix/monix-grpc#43

Modifications:

  • Remove the content-length in headers of the gRPC streaming response if set

Result:

  • A custom content-length is automatically stripped when response streaming is used in GrpcService.

Motivation:

If a wrong content-length is set, the request/stream is reset by
the Netty HTTP/2 codec. Most gRPC server call implmentations do not
set a `content-length` to response headers.

But some gRPC implementations such as Monix-gRPC send a `content-length`
which was the content-length of the request. I guess the runtime just
uses the incoming `Metadata` as the response `Metadata` without creating
a new one. Related: monix/monix-grpc#43

Modifications:

- Remove the `content-length` in headers of the gRPC streaming response
  if set

Result:

- A custom content-length is automatically stripped when response
  streaming is used in `GrpcService`.
@ikhoon ikhoon added the defect label Oct 4, 2022
@ikhoon ikhoon added this to the 1.20.0 milestone Oct 4, 2022
Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Thanks, @ikhoon! 👍

@ikhoon ikhoon force-pushed the remove-invalid-content-length branch from 414d466 to f77a8fd Compare October 4, 2022 15:33
@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Base: 74.10% // Head: 74.13% // Increases project coverage by 0.03% 🎉

Coverage data is based on head (f77a8fd) compared to base (1da6a6d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4460       /-   ##
============================================
  Coverage     74.10%   74.13%    0.03%     
- Complexity    18131    18155       24     
============================================
  Files          1529     1530        1     
  Lines         67229    67254       25     
  Branches       8494     8496        2     
============================================
  Hits          49820    49860       40     
  Misses        13350    13336      -14     
  Partials       4059     4058       -1     
Impacted Files Coverage Δ
...necorp/armeria/server/grpc/AbstractServerCall.java 89.14% <100.00%> ( 0.08%) ⬆️
...sting/junit4/server/SelfSignedCertificateRule.java 34.61% <0.00%> (-11.54%) ⬇️
...rnal/common/stream/AbstractFixedStreamMessage.java 89.23% <0.00%> (-3.08%) ⬇️
.../linecorp/armeria/client/ClientFactoryBuilder.java 73.49% <0.00%> (-2.51%) ⬇️
...corp/armeria/testing/junit4/server/ServerRule.java 48.83% <0.00%> (-2.33%) ⬇️
...easy/ResteasyAsynchronousExecutionContextImpl.java 53.48% <0.00%> (-2.33%) ⬇️
...ia/internal/common/SplitHttpMessageSubscriber.java 81.95% <0.00%> (-1.51%) ⬇️
.../armeria/server/eureka/EurekaUpdatingListener.java 67.12% <0.00%> (-1.37%) ⬇️
...rmeria/internal/client/grpc/ArmeriaClientCall.java 80.24% <0.00%> (-0.83%) ⬇️
...ia/common/stream/ConcatPublisherStreamMessage.java 80.62% <0.00%> (-0.78%) ⬇️
... and 20 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @ikhoon ! 🙇 👍 🙇

// implemented stubs such as Monix-gRPC. https://github.com/monix/monix-grpc/issues/43
// If a wrong content-length is set, an RST_STREAM error occurs at the Netty level.
// We don't need to care about the content-length of a unary call because it is eventually
// adjusted when the response is aggregated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Verified chunked encoding is used for http1 as well, so sgtm 👍

@minwoox minwoox merged commit e7209b6 into line:master Oct 5, 2022
@minwoox
Copy link
Member

minwoox commented Oct 5, 2022

Thanks, @ikhoon and @jrhee17!

@ikhoon ikhoon deleted the remove-invalid-content-length branch December 5, 2022 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants