jellyfin/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs

48 lines
1.3 KiB
C#
Raw Normal View History

using MediaBrowser.Common.Net;
2013-05-17 18:05:49 +00:00
using System.Collections.Generic;
using System.IO;
2016-11-12 06:58:50 +00:00
using System.Threading;
using System.Threading.Tasks;
2016-10-25 19:02:04 +00:00
using MediaBrowser.Model.Services;
2013-05-17 18:05:49 +00:00
namespace MediaBrowser.Api.Playback
{
/// <summary>
/// Class StaticRemoteStreamWriter
/// </summary>
2016-11-12 06:58:50 +00:00
public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
2013-05-17 18:05:49 +00:00
{
/// <summary>
/// The _input stream
/// </summary>
private readonly HttpResponseInfo _response;
2013-05-17 18:05:49 +00:00
/// <summary>
/// The _options
/// </summary>
private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
public StaticRemoteStreamWriter(HttpResponseInfo response)
2013-05-17 18:05:49 +00:00
{
_response = response;
2013-05-17 18:05:49 +00:00
}
/// <summary>
/// Gets the options.
/// </summary>
/// <value>The options.</value>
2016-10-25 19:02:04 +00:00
public IDictionary<string, string> Headers
2013-05-17 18:05:49 +00:00
{
get { return _options; }
}
2016-11-12 06:58:50 +00:00
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
2013-05-17 18:05:49 +00:00
{
using (_response)
{
2016-11-12 06:58:50 +00:00
await _response.Content.CopyToAsync(responseStream, 81920, cancellationToken).ConfigureAwait(false);
}
2013-05-17 18:05:49 +00:00
}
}
}