Skip to content

khellang/LimitsMiddleware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Limits Middleware

Build status NuGet Status NuGet Status

OWIN middleware to apply limits to an OWIN pipeline:

  • Max bandwidth
  • Max concurrent requests
  • Connection timeout
  • Max query string
  • Max request content length
  • Max url length

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)
            .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

Developed with:

Resharper TeamCity dotCover dotTrace

About

OWIN middleware to apply limits to an OWIN pipeline.

Resources

License

Stars

Watchers

Forks

Packages

No packages published