|
|
@ -141,16 +141,44 @@ namespace Emby.Server.Implementations.Services
|
|
|
|
response.ContentType += "; charset=utf-8";
|
|
|
|
response.ContentType += "; charset=utf-8";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var writeToOutputStreamResult = await WriteToOutputStream(response, result).ConfigureAwait(false);
|
|
|
|
var asyncStreamWriter = result as IAsyncStreamWriter;
|
|
|
|
if (writeToOutputStreamResult)
|
|
|
|
if (asyncStreamWriter != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await asyncStreamWriter.WriteToAsync(response.OutputStream, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var streamWriter = result as IStreamWriter;
|
|
|
|
|
|
|
|
if (streamWriter != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
streamWriter.WriteTo(response.OutputStream);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stream = result as Stream;
|
|
|
|
|
|
|
|
if (stream != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (stream)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
await stream.CopyToAsync(response.OutputStream).ConfigureAwait(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bytes = result as byte[];
|
|
|
|
|
|
|
|
if (bytes != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
response.ContentType = "application/octet-stream";
|
|
|
|
|
|
|
|
response.SetContentLength(bytes.Length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await response.OutputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var responseText = result as string;
|
|
|
|
var responseText = result as string;
|
|
|
|
if (responseText != null)
|
|
|
|
if (responseText != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var bytes = Encoding.UTF8.GetBytes(responseText);
|
|
|
|
bytes = Encoding.UTF8.GetBytes(responseText);
|
|
|
|
response.SetContentLength(bytes.Length);
|
|
|
|
response.SetContentLength(bytes.Length);
|
|
|
|
await response.OutputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
|
|
|
|
await response.OutputStream.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|