You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs

48 lines
1.3 KiB

using MediaBrowser.Common.Net;
using System.Collections.Generic;
using System.IO;
8 years ago
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.Playback
{
/// <summary>
/// Class StaticRemoteStreamWriter
/// </summary>
8 years ago
public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
{
/// <summary>
/// The _input stream
/// </summary>
private readonly HttpResponseInfo _response;
/// <summary>
/// The _options
/// </summary>
private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
public StaticRemoteStreamWriter(HttpResponseInfo response)
{
_response = response;
}
/// <summary>
/// Gets the options.
/// </summary>
/// <value>The options.</value>
public IDictionary<string, string> Headers
{
get { return _options; }
}
8 years ago
public async Task WriteToAsync(Stream responseStream, CancellationToken cancellationToken)
{
using (_response)
{
8 years ago
await _response.Content.CopyToAsync(responseStream, 81920, cancellationToken).ConfigureAwait(false);
}
}
}
}