public static void WriteBytesToResponse(this IResponse res, byte[] responseBytes, string contentType)
{
res.ContentType = HostContext.Config.AppendUtf8CharsetOnContentTypes.Contains(contentType)
? contentType + ContentFormat.Utf8Suffix
: contentType;
res.ApplyGlobalResponseHeaders();
res.SetContentLength(responseBytes.Length);
try
{
res.OutputStream.Write(responseBytes, 0, responseBytes.Length);
res.Flush();
}
catch (Exception ex)
{
ex.HandleResponseWriteException(res.Request, res, contentType);
}
finally
{
res.EndRequest(skipHeaders: true);
}
}