Skip to content

grpc-json: no buffering at end_stream or non-gRPC response#2363

Merged
htuch merged 9 commits intoenvoyproxy:masterfrom
lizan:grpc_transcoder_timeout
Jan 17, 2018
Merged

grpc-json: no buffering at end_stream or non-gRPC response#2363
htuch merged 9 commits intoenvoyproxy:masterfrom
lizan:grpc_transcoder_timeout

Conversation

@lizan
Copy link
Copy Markdown
Member

@lizan lizan commented Jan 13, 2018

Signed-off-by: Lizan Zhou zlizan@google.com

Description:
Make gRPC-JSON transcoder not buffering response at end_stream or non-gRPC response.

Risk Level: Low

Testing:
unit test

Docs Changes:
N/A

Release Notes:
N/A

Fixes #2275

Signed-off-by: Lizan Zhou <zlizan@google.com>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM, small nits. Thanks for fixing!

};

bool isGrpcResponse(const Http::HeaderMap& headers) {
if (strcmp("200", headers.Status()->value().c_str()) != 0) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use getResponseStatus here to match similar code elsewhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

return false;
}
return headers.ContentType() &&
Http::Headers::get().ContentTypeValues.Grpc == headers.ContentType()->value().c_str();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this will cause a string temporary to be created. If you invert it won't:
headers.ContentType()->value() == Http::Headers::get().ContentTypeValues.Grpc.c_str()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

I'm fine either though I don't think it will make a string temporary, as <string> defines:

bool operator== (const string& lhs, const char*   rhs);

http://www.cplusplus.com/reference/string/string/operators/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, good to know. Thanks for pointing that out.

mattklein123
mattklein123 previously approved these changes Jan 14, 2018
if (Http::Utility::getResponseStatus(headers) != 200) {
return false;
}
return headers.ContentType() &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this use https://github.com/envoyproxy/envoy/blob/master/source/common/grpc/common.cc#L25? Maybe this util belongs in Grpc::Common as well.

Signed-off-by: Lizan Zhou <zlizan@google.com>
public:
/**
* @param headers the headers to parse.
* @param bool indicating wether the header is at end_stream.
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 Jan 17, 2018

Choose a reason for hiding this comment

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

? (I think you meant to put this below)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oops, done.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM other than small comment.

lizan added 3 commits January 16, 2018 18:27
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
Signed-off-by: Lizan Zhou <zlizan@google.com>
@htuch htuch merged commit 1a46b84 into envoyproxy:master Jan 17, 2018
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Improves security with respect to third-party actions. See:
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions

I also read through the recent commits and updated to the latest release, since it contained a few bugfixes.

Risk: Low
Testing: CI

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Improves security with respect to third-party actions. See:
https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions

I also read through the recent commits and updated to the latest release, since it contained a few bugfixes.

Risk: Low
Testing: CI

Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants