Skip to content

Commit

Permalink
Revert "get static empty header only once when doing multiple evaluat…
Browse files Browse the repository at this point in the history
…ions with same context"

This reverts commit 41a54ba.
  • Loading branch information
wbpcode committed Nov 4, 2023
1 parent 3b411f3 commit cae6f1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions envoy/formatter/substitution_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class HttpFormatterContext {
AccessLog::AccessLogType accessLogType() const;

private:
mutable const Http::RequestHeaderMap* request_headers_{};
mutable const Http::ResponseHeaderMap* response_headers_{};
mutable const Http::ResponseTrailerMap* response_trailers_{};
const Http::RequestHeaderMap* request_headers_{};
const Http::ResponseHeaderMap* response_headers_{};
const Http::ResponseTrailerMap* response_trailers_{};
absl::string_view local_reply_body_{};
AccessLog::AccessLogType log_type_{AccessLog::AccessLogType::NotSet};
};
Expand Down
18 changes: 6 additions & 12 deletions source/common/formatter/http_specific_formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,16 @@ HttpFormatterContext::HttpFormatterContext(const Http::RequestHeaderMap* request
log_type_(log_type) {}

const Http::RequestHeaderMap& HttpFormatterContext::requestHeaders() const {
if (request_headers_ == nullptr) {
request_headers_ = Http::StaticEmptyHeaders::get().request_headers.get();
}
return *request_headers_;
return request_headers_ != nullptr ? *request_headers_
: *Http::StaticEmptyHeaders::get().request_headers;
}
const Http::ResponseHeaderMap& HttpFormatterContext::responseHeaders() const {
if (response_headers_ == nullptr) {
response_headers_ = Http::StaticEmptyHeaders::get().response_headers.get();
}
return *response_headers_;
return response_headers_ != nullptr ? *response_headers_
: *Http::StaticEmptyHeaders::get().response_headers;
}
const Http::ResponseTrailerMap& HttpFormatterContext::responseTrailers() const {
if (response_trailers_ == nullptr) {
response_trailers_ = Http::StaticEmptyHeaders::get().response_trailers.get();
}
return *response_trailers_;
return response_trailers_ != nullptr ? *response_trailers_
: *Http::StaticEmptyHeaders::get().response_trailers;
}

absl::string_view HttpFormatterContext::localReplyBody() const { return local_reply_body_; }
Expand Down

0 comments on commit cae6f1f

Please sign in to comment.