-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
grpc to support empty response. #1009
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,26 @@ TEST_F(GrpcRequestImplTest, ShortBodyInResponse) { | |
http_callbacks_->onSuccess(std::move(response_http_message)); | ||
} | ||
|
||
TEST_F(GrpcRequestImplTest, EmptyBodyInResponse) { | ||
expectNormalRequest(); | ||
|
||
helloworld::HelloRequest request; | ||
request.set_name("a name"); | ||
helloworld::HelloReply response; | ||
EXPECT_CALL(grpc_callbacks_, onPreRequestCustomizeHeaders(_)); | ||
service_.SayHello(nullptr, &request, &response, nullptr); | ||
|
||
Http::MessagePtr response_http_message(new Http::ResponseMessageImpl( | ||
Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{":status", "200"}}})); | ||
helloworld::HelloReply inner_response; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: empty_response might be more clear There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
response_http_message->body() = Common::serializeBody(inner_response); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
response_http_message->trailers( | ||
Http::HeaderMapPtr{new Http::TestHeaderMapImpl{{"grpc-status", "0"}}}); | ||
|
||
EXPECT_CALL(grpc_callbacks_, onSuccess()); | ||
http_callbacks_->onSuccess(std::move(response_http_message)); | ||
} | ||
|
||
TEST_F(GrpcRequestImplTest, BadMessageInResponse) { | ||
expectNormalRequest(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: http_response->body()->length() < 5, seems to be more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done