File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -71,4 +71,13 @@ public static string GetClientName(HttpContext context)
7171
7272 return result ;
7373 }
74+
75+ private static string ? GetSuperClient ( HttpContext context )
76+ {
77+ if ( context . Request . Headers . TryGetValue ( Constants . CLIENT_HEADER_NAME , out var superClient ) )
78+ if ( string . IsNullOrWhiteSpace ( superClient ) is false )
79+ return superClient ;
80+
81+ return context . Request . Query [ Constants . CLIENT_HEADER_NAME . ToLowerInvariant ( ) ] ;
82+ }
7483}
Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ private bool IsValidRequest(HttpContext context)
6262 if ( options . Value . ValidateClients is false || context . Request . Path . StartsWithSegments ( "/metrics" ) )
6363 return true ;
6464
65- return context . Request . Headers . ContainsKey ( Constants . CLIENT_HEADER_NAME )
66- && context . Request . Headers . ContainsKey ( Constants . CONTACT_HEADER_NAME ) ;
65+ return HasSuperHeaderOrQuery ( context , Constants . CLIENT_HEADER_NAME )
66+ && HasSuperHeaderOrQuery ( context , Constants . CONTACT_HEADER_NAME ) ;
6767 }
6868
6969 private RateLimiter GetRateLimiter ( HttpContext http )
@@ -122,4 +122,12 @@ private async Task RejectRequest(HttpContext context)
122122
123123 await writer . FlushAsync ( context . RequestAborted ) ;
124124 }
125+
126+ private bool HasSuperHeaderOrQuery ( HttpContext context , string name )
127+ {
128+ if ( context . Request . Headers . ContainsKey ( name ) )
129+ return true ;
130+
131+ return context . Request . Query . ContainsKey ( name . ToLowerInvariant ( ) ) ;
132+ }
125133}
You can’t perform that action at this time.
0 commit comments