Skip to content

async_client: minor refactor to response body handling#13339

Merged
alyssawilk merged 1 commit intoenvoyproxy:masterfrom
alyssawilk:datadog2
Oct 1, 2020
Merged

async_client: minor refactor to response body handling#13339
alyssawilk merged 1 commit intoenvoyproxy:masterfrom
alyssawilk:datadog2

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

As a follow-up to #13328, always creating a body buffer to avoid the pattern of null pointer derefs.

Risk Level: Medium
Testing: unit tests pass
Docs Changes: n/a
Release Notes: yes

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
if (request_length > 0) {
message->body() =
std::make_unique<Buffer::OwnedImpl>(request.attributes().request().http().body());
message->body().add(request.attributes().request().http().body());
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.

NIce! Thanks!

@mattklein123 mattklein123 self-assigned this Sep 30, 2020
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.

Very nice!

if (status_code == enumToInt(Http::Code::OK)) {
ENVOY_LOG(debug, "fetch remote data [uri = {}]: success", uri_.uri());
if (response->body()) {
if (response->body().length() > 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.

Might be worth it to add an empty() method to Buffer at some point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

haha yeah, I'm so used to getting reminded to use empty() over length() > 0 I started with that and was surprised when it didn't compile :-P

@alyssawilk alyssawilk merged commit 9fadf12 into envoyproxy:master Oct 1, 2020
@alyssawilk alyssawilk deleted the datadog2 branch June 10, 2021 13:43
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