https://github.com/tugberkugurlu/owin.limits
OWIN middleware to apply limits to an OWIN pipeline.
https://github.com/tugberkugurlu/owin.limits
Last synced: 5 months ago
JSON representation
OWIN middleware to apply limits to an OWIN pipeline.
- Host: GitHub
- URL: https://github.com/tugberkugurlu/owin.limits
- Owner: tugberkugurlu
- License: mit
- Created: 2014-05-26T08:50:52.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-27T08:19:05.000Z (almost 11 years ago)
- Last Synced: 2023-03-12T01:42:38.580Z (about 2 years ago)
- Language: C#
- Homepage:
- Size: 6.11 MB
- Stars: 2
- Watchers: 1
- Forks: 22
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Owin.Limits
===========OWIN middleware to apply limits to an OWIN pipeline. Install via [nuget].
#### Implemented:
- Max bandwidth
- Max concurrent requests
- Connection timeout
- Max query string
- Max request content length
- Max url length
#### TODO:
- Header limits?
- Per request limits#### IAppBuilder
Owin.dll and IAppBuilder is deprecated. As of version 2.0.0, Owin.Limits no longer depends on owin.dll. To provide compatibility with IAppBuilder, add the following class to your application:
```csharp
namespace Owin
{
using System;
using Owin.Limits;internal static class AppBuilderExtensions
{
internal static Action Use(this IAppBuilder builder)
{
return middleware => builder.Use(middleware);
}internal static IAppBuilder Use(this Action middleware, IAppBuilder builder)
{
return builder;
}
}
}
```#### Examples
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 the above `AppBuilderExtensions` class in your application.
```csharp
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.
Pull requests gratefully accepted.
Thanks to the following contributors!
- [Stefan Ossendorf](https://github.com/StefanOssendorf) ([@Pherenetic](https://twitter.com/Pherenetic))[nuget]: https://www.nuget.org/packages/Owin.Limits
[@randompunter]: http://twitter.com/randompunter