mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-30 04:34:49 +03:00
update components
This commit is contained in:
@@ -4,13 +4,15 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using ServiceStack;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
/// <summary>
|
||||
/// Class StreamWriter
|
||||
/// </summary>
|
||||
public class StreamWriter : IStreamWriter, IHasOptions
|
||||
public class StreamWriter : IStreamWriter, /*IAsyncStreamWriter,*/ IHasOptions
|
||||
{
|
||||
private ILogger Logger { get; set; }
|
||||
|
||||
@@ -73,24 +75,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
}
|
||||
|
||||
// 256k
|
||||
private const int BufferSize = 262144;
|
||||
|
||||
/// <summary>
|
||||
/// Writes to.
|
||||
/// </summary>
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
public void WriteTo(Stream responseStream)
|
||||
{
|
||||
WriteToInternal(responseStream);
|
||||
}
|
||||
|
||||
// 256k
|
||||
private const int BufferSize = 262144;
|
||||
|
||||
/// <summary>
|
||||
/// Writes to async.
|
||||
/// </summary>
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private void WriteToInternal(Stream responseStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -107,7 +99,36 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
OnError();
|
||||
}
|
||||
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (OnComplete != null)
|
||||
{
|
||||
OnComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task WriteToAsync(Stream responseStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var src = SourceStream)
|
||||
{
|
||||
await src.CopyToAsync(responseStream, BufferSize).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.ErrorException("Error streaming data", ex);
|
||||
|
||||
if (OnError != null)
|
||||
{
|
||||
OnError();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user