Skip to content

Commit

Permalink
logging: Add has() methods for to HttpFormatterContext (envoyproxy#31022
Browse files Browse the repository at this point in the history
)

logging: Add has() methods for to HttpFormatterContext

HttpFormatterContext was recently added to store request headers, response headers and trailers. It provides simple accessors for those which return the static empty maps if not present. However, there are some envoy users which would like to test if the headers are present or not.

Signed-off-by: Ryan Hamilton <[email protected]>
  • Loading branch information
RyanTheOptimist authored Nov 24, 2023
1 parent be410d6 commit acc54c5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions envoy/formatter/http_formatter_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,33 @@ class HttpFormatterContext {
*/
const Http::RequestHeaderMap& requestHeaders() const;

/**
* @return false if no request headers are available.
*/
bool hasRequestHeaders() const { return request_headers_ != nullptr; }

/**
* @return const Http::ResponseHeaderMap& the response headers. Empty respnose header map if
* no response headers are available.
*/
const Http::ResponseHeaderMap& responseHeaders() const;

/**
* @return false if no response headers are available.
*/
bool hasResponseHeaders() const { return response_headers_ != nullptr; }

/**
* @return const Http::ResponseTrailerMap& the response trailers. Empty response trailer map
* if no response trailers are available.
*/
const Http::ResponseTrailerMap& responseTrailers() const;

/**
* @return false if no response trailers are available.
*/
bool hasResponseTrailers() const { return response_trailers_ != nullptr; }

/**
* @return absl::string_view the local reply body. Empty if no local reply body.
*/
Expand Down

0 comments on commit acc54c5

Please sign in to comment.