@@ -144,14 +144,18 @@ private void OnCancellation() {
144144
145145 // uses config to determine if a request should be failed
146146 private FailMode ShouldFail ( Request r ) {
147- if ( _throttledRequests . TryGetValue ( r . Url , out DateTime retryAfterDate ) ) {
147+ string key = BuildThrottleKey ( r ) ;
148+ if ( _throttledRequests . TryGetValue ( key , out DateTime retryAfterDate ) ) {
148149 if ( retryAfterDate > DateTime . Now ) {
149150 Console . Error . WriteLine ( $ "Calling { r . Url } again before waiting for the Retry-After period. Request will be throttled") ;
151+ // update the retryAfterDate to extend the throttling window to ensure that brute forcing won't succeed.
152+ _throttledRequests [ key ] = retryAfterDate . AddSeconds ( retryAfterInSeconds ) ;
150153 return FailMode . Throttled ;
151154 }
152155 else {
153- // clean up expired throttled request
156+ // clean up expired throttled request and ensure that this request is passed through.
154157 _throttledRequests . Remove ( r . Url ) ;
158+ return FailMode . PassThru ;
155159 }
156160 }
157161
@@ -291,7 +295,7 @@ _config.Responses is null ||
291295 private void UpdateProxyResponse ( SessionEventArgs e , ResponseComponents responseComponents , ChaosProxyMockResponse ? matchingResponse ) {
292296 if ( responseComponents . ErrorStatus == HttpStatusCode . TooManyRequests ) {
293297 var retryAfterDate = DateTime . Now . AddSeconds ( retryAfterInSeconds ) ;
294- _throttledRequests [ e . HttpClient . Request . Url ] = retryAfterDate ;
298+ _throttledRequests [ BuildThrottleKey ( e . HttpClient . Request ) ] = retryAfterDate ;
295299 responseComponents . Headers . Add ( new HttpHeader ( "Retry-After" , retryAfterInSeconds . ToString ( ) ) ) ;
296300 }
297301
@@ -311,6 +315,8 @@ private void UpdateProxyResponse(SessionEventArgs e, ResponseComponents response
311315 e . GenericResponse ( responseComponents . Body ?? string . Empty , responseComponents . ErrorStatus , responseComponents . Headers ) ;
312316 }
313317
318+ private string BuildThrottleKey ( Request r ) => $ "{ r . Method } -{ r . Url } ";
319+
314320 // Modify response
315321 async Task OnResponse ( object sender , SessionEventArgs e ) {
316322 // read response headers
0 commit comments