Scenario: Use Web API request batching on Owin.
Our DefaultHttpBatchHandler requires us to supply the HttpServer instance to it, so I cannot use the 'UseWebApi' extension here. So, I am using the 'UseMessageHandler' extension:
```
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomBufferPolicySelector());
HttpServer server = new HttpServer(config);
config.MapHttpAttributeRoutes();
config.Routes.MapHttpBatchRoute("batchRoute", "api/$batch", new DefaultHttpBatchHandler(httpServer: server));
appBuilder.UseHttpMessageHandler(messageHandler: server);
}
```
Also the 'UseHttpMessageHandler' (below) uses the default buffer policy selector and does not take the buffer policy from the configuration of HttpServer
```
/// <summary>
/// Adds a component to the OWIN pipeline for running an <see cref="HttpMessageHandler"/>.
/// </summary>
/// <param name="builder">The application builder.</param>
/// <param name="messageHandler">The message handler.</param>
/// <returns>The application builder.</returns>
public static IAppBuilder UseHttpMessageHandler(this IAppBuilder builder, HttpMessageHandler messageHandler)
{
return builder.Use(typeof(HttpMessageHandlerAdapter), messageHandler, _defaultBufferPolicySelector);
}
```
We need a convenient extension for users to be able to supply the HttpServer instance.
Comments: Verified.
Our DefaultHttpBatchHandler requires us to supply the HttpServer instance to it, so I cannot use the 'UseWebApi' extension here. So, I am using the 'UseMessageHandler' extension:
```
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Services.Replace(typeof(IHostBufferPolicySelector), new CustomBufferPolicySelector());
HttpServer server = new HttpServer(config);
config.MapHttpAttributeRoutes();
config.Routes.MapHttpBatchRoute("batchRoute", "api/$batch", new DefaultHttpBatchHandler(httpServer: server));
appBuilder.UseHttpMessageHandler(messageHandler: server);
}
```
Also the 'UseHttpMessageHandler' (below) uses the default buffer policy selector and does not take the buffer policy from the configuration of HttpServer
```
/// <summary>
/// Adds a component to the OWIN pipeline for running an <see cref="HttpMessageHandler"/>.
/// </summary>
/// <param name="builder">The application builder.</param>
/// <param name="messageHandler">The message handler.</param>
/// <returns>The application builder.</returns>
public static IAppBuilder UseHttpMessageHandler(this IAppBuilder builder, HttpMessageHandler messageHandler)
{
return builder.Use(typeof(HttpMessageHandlerAdapter), messageHandler, _defaultBufferPolicySelector);
}
```
We need a convenient extension for users to be able to supply the HttpServer instance.
Comments: Verified.