Home

Awesome

Limits Middleware

Build status NuGet Status NuGet Status

OWIN middleware to apply limits to an OWIN pipeline:

Installation

There are two nuget packages. The main one is pure owin and this has no dependencies.

install-package LimitsMiddleware

The second package provides integration with IAppBuilder, which is deprecated but provided here for legacy and compatability reasons.

install-package LimitsMiddleware.OwinAppBuilder

An asp.net vNext builder integration package will be forthcoming.

Using

Configuration values can be supplied as constants or with a delegate. The latter allows you to change the values at runtime. Use which ever you see fit. This code assumes you have installed 'LimitsMiddleware.OwinAppBuilder'

public class Startup
{
    public void Configuration(IAppBuilder builder)
    {
        //static settings
        builder.Use()
            .MaxBandwidth(10000) //bps
            .MaxConcurrentRequests(10)
            .ConnectionTimeout(TimeSpan.FromSeconds(10))
            .MaxQueryStringLength(15) //Unescaped QueryString
            .MaxRequestContentLength(15)
            .MaxUrlLength(20)
            .MinResponseDelay(200ms)
            .UseEtc(..);
            
        //dynamic settings
        builder.Use()
            .MaxBandwidth(() => 10000) //bps
            .MaxConcurrentRequests(() => 10)
            .ConnectionTimeout(() => TimeSpan.FromSeconds(10))
            .MaxQueryStringLength(() => 15)
            .MaxRequestContentLength(() => 15)
            .MaxUrlLength(() => 20)
            .UseEtc(..);
    }
}

Questions or suggestions? Create an issue or [@randompunter] on twitter.

Help

Bugs? Create an issue. Questions @randompunter or OWIN room on Jabbr