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

Respond with application/json for httpjson transcoding endpoints #4474

Merged
merged 4 commits into from Oct 11, 2022

Conversation

mscheong01
Copy link
Contributor

@mscheong01 mscheong01 commented Oct 11, 2022

Motivation:

Wrong response contenttype served for http json transcoding endpoints as result of #4364

Modifications:

  • since AbstractUnframedGrpcService$frameAndServe uses the provided responseContentType parameter directly as the resulting http contenttype, application/json should be provided in HttpJsonTranscodingService instead of application/grpc+json
  • alternative would be to respond with the request contenttype ex) JSON -> JSON / JSON_UTF_8 -> JSON_UTF_8

Result:

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, @j-min5u! 😄

@@ -603,7 +602,7 @@ private HttpResponse serve0(ServiceRequestContext ctx, HttpRequest req,
ctx.setAttr(FramedGrpcService.RESOLVED_GRPC_METHOD, spec.method);
frameAndServe(unwrap(), ctx, grpcHeaders.build(),
convertToJson(ctx, clientRequest, spec),
responseFuture, generateResponseBodyConverter(spec), jsonContentType);
responseFuture, generateResponseBodyConverter(spec), MediaType.JSON_UTF_8);
Copy link
Member

Choose a reason for hiding this comment

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

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.

Thanks for the quick fix @j-min5u ! 🙇 👍 🙇

@jrhee17
Copy link
Contributor

jrhee17 commented Oct 11, 2022

Can you also check the lint failures? 😅

@ikhoon ikhoon added this to the 1.20.1 milestone Oct 11, 2022
@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 74.04% // Head: 74.08% // Increases project coverage by +0.03% 🎉

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

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4474      +/-   ##
============================================
+ Coverage     74.04%   74.08%   +0.03%     
- Complexity    18164    18173       +9     
============================================
  Files          1536     1536              
  Lines         67379    67378       -1     
  Branches       8520     8520              
============================================
+ Hits          49889    49914      +25     
+ Misses        13416    13401      -15     
+ Partials       4074     4063      -11     
Impacted Files Coverage Δ
...rmeria/server/grpc/HttpJsonTranscodingService.java 81.69% <100.00%> (-0.05%) ⬇️
...inecorp/armeria/server/file/StreamingHttpFile.java 54.78% <0.00%> (-2.61%) ⬇️
...p/armeria/common/stream/DeferredStreamMessage.java 81.39% <0.00%> (-1.75%) ⬇️
.../com/linecorp/armeria/server/RoutingPredicate.java 78.35% <0.00%> (-1.04%) ⬇️
...corp/armeria/common/logging/DefaultRequestLog.java 79.94% <0.00%> (-0.26%) ⬇️
...inecorp/armeria/server/HttpResponseSubscriber.java 80.60% <0.00%> (ø)
...com/linecorp/armeria/client/RedirectingClient.java 73.33% <0.00%> (+0.44%) ⬆️
...a/internal/common/stream/ByteBufsDecoderInput.java 87.76% <0.00%> (+0.71%) ⬆️
...armeria/client/HttpClientPipelineConfigurator.java 79.09% <0.00%> (+0.96%) ⬆️
...rp/armeria/common/stream/DefaultStreamMessage.java 89.47% <0.00%> (+1.05%) ⬆️
... and 12 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

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

LGTM and welcome back! 😁

@ikhoon ikhoon merged commit e272704 into line:master Oct 11, 2022
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.

HTTP/JSON gRPC transcoding services does not return application/json but applicaiton/grpc+json
4 participants