@@ -375,19 +375,20 @@ func logRequest(method, endpoint string, requestHeaders map[string]string, reque
375375
376376 if os .Getenv ("debug" ) == "1" || os .Getenv ("DEBUG" ) == "1" {
377377
378- // define sensitive headers (lowercase for comparison )
379- sensitiveHeaders := map [string ]bool {
380- "authorization" : true ,
381- "x-api-key" : true ,
382- "x-auth-token" : true ,
383- "cookie" : true ,
384- "set-cookie" : true ,
385- "client_secret " : true ,
386- "proxy-authorization" : true ,
378+ // sensitive headers (lowercase)
379+ sensitiveHeaders := map [string ]struct {} {
380+ "authorization" : {} ,
381+ "x-api-key" : {} ,
382+ "x-auth-token" : {} ,
383+ "cookie" : {} ,
384+ "set-cookie" : {} ,
385+ "client-secret " : {} ,
386+ "proxy-authorization" : {} ,
387387 }
388388
389389 maskIfSensitive := func (key , value string ) string {
390- if sensitiveHeaders [strings .ToLower (key )] {
390+ normalized := strings .ToLower (http .CanonicalHeaderKey (key ))
391+ if _ , exists := sensitiveHeaders [normalized ]; exists {
391392 return "***"
392393 }
393394 return value
@@ -402,8 +403,7 @@ func logRequest(method, endpoint string, requestHeaders map[string]string, reque
402403 var heads , rheads []string
403404
404405 for k , v := range requestHeaders {
405- maskedValue := maskIfSensitive (k , v )
406- heads = append (heads , fmt .Sprintf ("\t %s : %s" , k , maskedValue ))
406+ heads = append (heads , fmt .Sprintf ("\t %s : %s" , k , maskIfSensitive (k , v )))
407407 }
408408
409409 for k , v := range responseHeaders {
0 commit comments