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: Since batching is now a first class feature in Web API, I think we need to provide a more easily discoverable way of using it. Currently user has to figure out how he could achieve it with Katana. Also, if you notice in the second part of the bug, the appropriate buffer policy isn't being picked up too.
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: Since batching is now a first class feature in Web API, I think we need to provide a more easily discoverable way of using it. Currently user has to figure out how he could achieve it with Katana. Also, if you notice in the second part of the bug, the appropriate buffer policy isn't being picked up too.