@@ -35,18 +35,14 @@ public RequestThrottlingMiddleware(RequestDelegate next, ILoggerFactory loggerFa
35
35
{
36
36
throw new ArgumentException ( "The value of 'options.MaxConcurrentRequests' must be specified." , nameof ( options ) ) ;
37
37
}
38
- if ( _requestThrottlingOptions . MaxConcurrentRequests < 0 )
38
+ if ( _requestThrottlingOptions . MaxConcurrentRequests <= 0 )
39
39
{
40
- throw new ArgumentException ( "The value of ' options.MaxConcurrentRequests' must be a positive integer." , nameof ( options ) ) ;
40
+ throw new ArgumentOutOfRangeException ( nameof ( options ) , "The value of ` options.MaxConcurrentRequests` must be a positive integer." ) ;
41
41
}
42
42
if ( _requestThrottlingOptions . RequestQueueLimit < 0 )
43
43
{
44
44
throw new ArgumentException ( "The value of 'options.RequestQueueLimit' must be a positive integer." , nameof ( options ) ) ;
45
45
}
46
- if ( _requestThrottlingOptions . MaxConcurrentRequests <= 0 )
47
- {
48
- throw new ArgumentOutOfRangeException ( nameof ( options ) , "The value of `options.MaxConcurrentRequests` must be a positive integer." ) ;
49
- }
50
46
51
47
if ( _requestThrottlingOptions . OnRejected == null )
52
48
{
@@ -55,9 +51,15 @@ public RequestThrottlingMiddleware(RequestDelegate next, ILoggerFactory loggerFa
55
51
56
52
_next = next ;
57
53
_logger = loggerFactory . CreateLogger < RequestThrottlingMiddleware > ( ) ;
58
- _requestQueue = new TailDrop (
59
- _requestThrottlingOptions . MaxConcurrentRequests . Value ,
60
- _requestThrottlingOptions . RequestQueueLimit ) ;
54
+
55
+ if ( _requestThrottlingOptions . ServerAlwaysBlocks )
56
+ {
57
+ _requestQueue = new TailDrop ( 0 , _requestThrottlingOptions . RequestQueueLimit ) ;
58
+ }
59
+ else
60
+ {
61
+ _requestQueue = new TailDrop ( _requestThrottlingOptions . MaxConcurrentRequests . Value , _requestThrottlingOptions . RequestQueueLimit ) ;
62
+ }
61
63
}
62
64
63
65
/// <summary>
0 commit comments