OwinHttpMessageHandler Save Abandoned

An implementation of System.Net.Http.HttpMessageHandler that translates an HttpRequestMessage into an OWIN compatible environment dictionary

Project README

:warning: The package is no longer supported. If you have an application and require support, please contact me.

OwinHttpMessageHandler Build status NuGet Status

An implementation of System.Net.Http.HttpMessageHandler that translates an HttpRequestMessage into an OWIN compatible environment dictionary, calls the supplied AppFunc and translates the result to an HttpResponseMessage. This allows you to call an OWIN application / middleware using HttpClient without actually hitting the network stack. Useful for testing and embedded scenarios.

Install via nuget.

Using

var handler = new OwinHttpMessageHandler(appFunc) // Alternatively you can pass in a MidFunc
{
    UseCookies = true, // Will send cookies on subsequent requests. Default is false.
    AllowAutoRedirect = true // The handler will auto follow 301/302
}
var httpClient = new HttpClient(handler)
{
    BaseAddress = new Uri("http://localhost")
}

var response = await httpClient.GetAsync("/");

By default, the OWIN environment is defined to look as though the source of the request is local. You can adjust the OWIN environment via a delegate:

Func<IDictionary<string, object>, Task> appFunc;
...
var httpClient = new HttpClient(new OwinHttpMessageHandler(appFunc, env =>
{
    env[Constants.ServerRemoteIpAddressKey] ="10.1.1.1";
}));

More information on Http Message Handlers

Licence : MIT

Follow me @randompunter

Open Source Agenda is not affiliated with "OwinHttpMessageHandler" Project. README Source: damianh/OwinHttpMessageHandler
Stars
39
Open Issues
0
Last Commit
4 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating