damianh / LimitsMiddleware

OWIN middleware to apply limits to an OWIN pipeline.
MIT License
0 stars 0 forks source link

New Limit: MinResponseDelay ability to add a configurable delay (latency) to each response. #18

Closed damianh closed 7 years ago

damianh commented 9 years ago

The goal here it to be able to plug in a back-off algorithm to slow down requests i.e. in the case of a brute force. As a separate benefit, could be used to simulate a server under load.

Requires an int which represents delay in milisecondswhere <= 0 means no delay. Q: Should there be a max value?

app.MinResponseDelay(50) app.MinResponseDelay(() => 50) app.MinResponseDelay(request => calcValue)

return next => env => 
{
    var delay = _getDelay();
    // check delay doesn't exceed max.
    if(delay > 0)
    {
        await Task.Delay(delay);
    }
    await next(env):
}