Skip to content

Commit 1d7b521

Browse files
astandrikadameat
authored andcommitted
Add X-Trace-Verbosity header for tracing (ydb-platform#7183)
1 parent d06b473 commit 1d7b521

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

ydb/core/viewer/viewer.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,36 @@ class TViewer : public TActorBootstrapped<TViewer>, public IViewer {
536536
if (type.empty()) {
537537
type = "application/json";
538538
}
539-
TStringBuilder response;
540-
response << "HTTP/1.1 204 No Content\r\n";
541-
FillCORS(response, msg);
542-
response << "Content-Type: " + type + "\r\n"
543-
"Connection: Keep-Alive\r\n\r\n";
544-
Send(ev->Sender, new NMon::TEvHttpInfoRes(response, 0, NMon::IEvHttpInfoRes::EContentType::Custom));
539+
if (AllowOrigin) {
540+
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
541+
"HTTP/1.1 204 No Content\r\n"
542+
"Access-Control-Allow-Origin: " + AllowOrigin + "\r\n"
543+
"Access-Control-Allow-Credentials: true\r\n"
544+
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
545+
"Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n"
546+
"Allow: OPTIONS, GET, POST\r\n"
547+
"Content-Type: " + type + "\r\n"
548+
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
549+
} else {
550+
TString origin = TString(msg->Request.GetHeader("Origin"));
551+
if (!origin.empty()) {
552+
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
553+
"HTTP/1.1 204 No Content\r\n"
554+
"Access-Control-Allow-Origin: " + origin + "\r\n"
555+
"Access-Control-Allow-Credentials: true\r\n"
556+
"Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
557+
"Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n"
558+
"Allow: OPTIONS, GET, POST\r\n"
559+
"Content-Type: " + type + "\r\n"
560+
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
561+
} else {
562+
ctx.Send(ev->Sender, new NMon::TEvHttpInfoRes(
563+
"HTTP/1.1 204 No Content\r\n"
564+
"Allow: OPTIONS, GET, POST\r\n"
565+
"Content-Type: " + type + "\r\n"
566+
"Connection: Keep-Alive\r\n\r\n", 0, NMon::IEvHttpInfoRes::EContentType::Custom));
567+
}
568+
}
545569
return;
546570
}
547571
TString path("/" + msg->Request.GetPage()->Path + msg->Request.GetPathInfo());
@@ -652,8 +676,7 @@ void TViewer::FillCORS(TStringBuilder& stream, const TRequestState& request) {
652676
stream << "Access-Control-Allow-Origin: " << origin << "\r\n"
653677
<< "Access-Control-Allow-Credentials: true\r\n"
654678
<< "Access-Control-Allow-Headers: Content-Type,Authorization,Origin,Accept,X-Trace-Verbosity,X-Want-Trace\r\n"
655-
<< "Access-Control-Allow-Methods: OPTIONS, GET, POST, DELETE\r\n"
656-
<< "Allow: OPTIONS, GET, POST, DELETE\r\n";
679+
<< "Access-Control-Allow-Methods: OPTIONS, GET, POST\r\n";
657680
}
658681
}
659682

0 commit comments

Comments
 (0)