Skip to content

gerwout/LimitsMiddleware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Limits Middleware

Join the chat at https://gitter.im/damianh/LimitsMiddleware

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
            .MaxBandwidth(10000) //bps
            .MaxConcurrentRequests(10)
            .ConnectionTimeout(TimeSpan.FromSeconds(10))
            .MaxQueryStringLength(15) //Unescaped QueryString
            .MaxRequestContentLength(15)
            .MaxUrlLength(20)
            .UseEtc(..);
            
        //dynamic settings
        builder
            .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

Languages

  • C# 98.3%
  • PowerShell 1.1%
  • HTML 0.6%