Skip to content

Commit 1ece0cd

Browse files
authored
clang tidy: fix a minor left clang tidy problem of source (#45080)
1 parent bd28a2f commit 1ece0cd

1 file changed

Lines changed: 7 additions & 20 deletions

File tree

source/extensions/filters/common/ext_authz/ext_authz_http_impl.cc

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,12 @@ Http::Code zeroHttpCode() {
3838
return static_cast<Http::Code>(0);
3939
}
4040

41-
// Static response used for creating authorization ERROR responses.
41+
// Response used for creating authorization ERROR responses.
4242
// Note: status_code is left unset so the filter can use the configured status_on_error
4343
// configuration.
44-
const Response& errorResponse() {
45-
CONSTRUCT_ON_FIRST_USE(Response, Response{CheckStatus::Error,
46-
UnsafeHeaderVector{},
47-
UnsafeHeaderVector{},
48-
UnsafeHeaderVector{},
49-
UnsafeHeaderVector{},
50-
UnsafeHeaderVector{},
51-
UnsafeHeaderVector{},
52-
UnsafeHeaderVector{},
53-
false,
54-
{{}},
55-
Http::Utility::QueryParamsVector{},
56-
{},
57-
EMPTY_STRING,
58-
zeroHttpCode(),
59-
Protobuf::Struct{}});
44+
ResponsePtr errorResponse() {
45+
return std::make_unique<Response>(
46+
Response{.status = CheckStatus::Error, .status_code = zeroHttpCode()});
6047
}
6148

6249
// Static matcher that never matches anything. Used for matchers that are not applicable
@@ -376,7 +363,7 @@ void RawHttpClientImpl::check(RequestCallbacks& callbacks,
376363
if (thread_local_cluster == nullptr) {
377364
// TODO(dio): Add stats related to this.
378365
ENVOY_LOG(debug, "ext_authz cluster '{}' does not exist", cluster);
379-
callbacks_->onComplete(std::make_unique<Response>(errorResponse()));
366+
callbacks_->onComplete(errorResponse());
380367
callbacks_ = nullptr;
381368
} else {
382369
// Do not enforce a sampling decision on this span; instead keep the parent's sampling status.
@@ -409,7 +396,7 @@ void RawHttpClientImpl::onFailure(const Http::AsyncClient::Request&,
409396
// TODO(botengyao): handle different failure reasons.
410397
ASSERT(reason == Http::AsyncClient::FailureReason::Reset ||
411398
reason == Http::AsyncClient::FailureReason::ExceedResponseBufferLimit);
412-
callbacks_->onComplete(std::make_unique<Response>(errorResponse()));
399+
callbacks_->onComplete(errorResponse());
413400
callbacks_ = nullptr;
414401
}
415402

@@ -432,7 +419,7 @@ ResponsePtr RawHttpClientImpl::toResponse(Http::ResponseMessagePtr message) {
432419
// codes. A Forbidden response is sent to the client if the filter has not been configured with
433420
// failure_mode_allow.
434421
if (Http::CodeUtility::is5xx(status_code)) {
435-
return std::make_unique<Response>(errorResponse());
422+
return errorResponse();
436423
}
437424

438425
// Extract headers-to-remove from the storage header coming from the

0 commit comments

Comments
 (0)