File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
m365-developer-proxy-plugins/Behavior Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -244,10 +244,21 @@ _urlsToWatch is null ||
244244 var headers = _configuration . CustomResponse . ResponseHeaders is not null ?
245245 _configuration . CustomResponse . ResponseHeaders . Select ( h => new HttpHeader ( h . Key , h . Value ) ) :
246246 Array . Empty < HttpHeader > ( ) ;
247+
248+ // allow custom throttling response
249+ var responseCode = ( HttpStatusCode ) ( _configuration . CustomResponse . ResponseCode ?? 200 ) ;
250+ if ( responseCode == HttpStatusCode . TooManyRequests ) {
251+ e . ThrottledRequests . Add ( new ThrottlerInfo (
252+ BuildThrottleKey ( request ) ,
253+ ShouldThrottle ,
254+ DateTime . Now . AddSeconds ( _configuration . RetryAfterSeconds )
255+ ) ) ;
256+ }
257+
247258 string body = _configuration . CustomResponse . ResponseBody is not null ?
248259 JsonSerializer . Serialize ( _configuration . CustomResponse . ResponseBody , new JsonSerializerOptions { WriteIndented = true } ) :
249260 "" ;
250- e . Session . GenericResponse ( body , ( HttpStatusCode ) ( _configuration . CustomResponse . ResponseCode ?? 200 ) , headers ) ;
261+ e . Session . GenericResponse ( body , responseCode , headers ) ;
251262 state . HasBeenSet = true ;
252263 }
253264 else
You can’t perform that action at this time.
0 commit comments