From 90ca73af134223d9bb7cb31549b8faf57fd6209d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 21 Jun 2019 16:47:51 -0700 Subject: [PATCH] Allow trace even if server is not initialized (#7822) --- cmd/admin-handlers.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index 8ad5a9f75..5455857db 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -1432,10 +1432,19 @@ func (a adminAPIHandlers) SetConfigKeysHandler(w http.ResponseWriter, r *http.Re func (a adminAPIHandlers) TraceHandler(w http.ResponseWriter, r *http.Request) { ctx := newContext(r, w, "HTTPTrace") trcAll := r.URL.Query().Get("all") == "true" - objectAPI := validateAdminReq(ctx, w, r) - if objectAPI == nil { + + // Validate request signature. + adminAPIErr := checkAdminRequestAuthType(ctx, r, "") + if adminAPIErr != ErrNone { + writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) + return + } + + if globalTrace == nil { + writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL) return } + // Avoid reusing tcp connection if read timeout is hit // This is needed to make r.Context().Done() work as // expected in case of read timeout