Plugins like webmarkupmin modify the HTTP response body from the HTTPContext using an HTTP module like this:
protected override void ProcessContent(HttpContext context)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
Encoding encoding = response.ContentEncoding;
string contentType = response.ContentType;
if (request.HttpMethod == "GET" && response.StatusCode == 200
&& contentType == ContentType.Html
&& context.CurrentHandler != null)
{
var htmlMinifier = WebMarkupMinContext.Current.Markup.CreateHtmlMinifierInstance();
response.Filter = new HtmlMinificationFilterStream(response.Filter, htmlMinifier,
request.RawUrl, encoding);
if (WebMarkupMinContext.Current.IsCopyrightHttpHeadersEnabled())
{
CopyrightHelper.AddHtmlMinificationPoweredByHttpHeader(response);
}
}
}
How would you modify the raw HTTP response body per request using the new HTTP Pipeline in ASP.NET 5?