Skip to content

Commit e7c1a9f

Browse files
committed
fix core: immediately ret when limit for log=0
Relates: <HIDDEN_URL> commit_hash:d54afc6b398fc892b139797b303180ce9dcec545
1 parent 5da918f commit e7c1a9f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

core/src/server/handlers/http_handler_base.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,12 @@ std::string HttpHandlerBase::GetRequestBodyForLoggingChecked(
367367
const std::string& request_body
368368
) const {
369369
try {
370-
return GetRequestBodyForLogging(request, context, request_body);
370+
const auto limit = GetConfig().request_body_size_log_limit;
371+
if (limit == 0) {
372+
return utils::log::ToLimitedUtf8(request_body, 0);
373+
}
374+
auto logging_request_body = GetRequestBodyForLogging(request, context, request_body);
375+
return utils::log::ToLimitedUtf8(logging_request_body, limit);
371376
} catch (const std::exception& ex) {
372377
LOG_LIMITED_ERROR() << "failed to get request body for logging: " << ex;
373378
return "<error in GetRequestBodyForLogging>";
@@ -380,7 +385,12 @@ std::string HttpHandlerBase::GetResponseDataForLoggingChecked(
380385
const std::string& response_data
381386
) const {
382387
try {
383-
return GetResponseDataForLogging(request, context, response_data);
388+
const auto limit = GetConfig().response_data_size_log_limit;
389+
if (limit == 0) {
390+
return utils::log::ToLimitedUtf8(response_data, 0);
391+
}
392+
auto logging_response_data = GetResponseDataForLogging(request, context, response_data);
393+
return utils::log::ToLimitedUtf8(logging_response_data, limit);
384394
} catch (const std::exception& ex) {
385395
LOG_LIMITED_ERROR() << "failed to get response data for logging: " << ex;
386396
return "<error in GetResponseDataForLogging>";

0 commit comments

Comments
 (0)