mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-08-11 09:13:54 -04:00
Added DisposeResponseStream method to BaseHandler
This commit is contained in:
parent
442b9c559f
commit
dc90725d61
@ -13,6 +13,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IDictionary<string, string> Headers = new Dictionary<string, string>();
|
public IDictionary<string, string> Headers = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
private Stream CompressedStream { get; set; }
|
||||||
|
|
||||||
public virtual bool UseChunkedEncoding
|
public virtual bool UseChunkedEncoding
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -54,7 +56,7 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||||||
|
|
||||||
if (!IsAsyncHandler)
|
if (!IsAsyncHandler)
|
||||||
{
|
{
|
||||||
s.Dispose();
|
DisposeResponseStream();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -127,10 +129,9 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||||||
{
|
{
|
||||||
if (CompressResponse)
|
if (CompressResponse)
|
||||||
{
|
{
|
||||||
using (DeflateStream compressedStream = new DeflateStream(stream, CompressionLevel.Fastest, false))
|
CompressedStream = new DeflateStream(stream, CompressionLevel.Fastest, false);
|
||||||
{
|
|
||||||
WriteResponseToOutputStream(compressedStream);
|
WriteResponseToOutputStream(CompressedStream);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -140,5 +141,14 @@ namespace MediaBrowser.Common.Net.Handlers
|
|||||||
|
|
||||||
protected abstract void WriteResponseToOutputStream(Stream stream);
|
protected abstract void WriteResponseToOutputStream(Stream stream);
|
||||||
|
|
||||||
|
protected void DisposeResponseStream()
|
||||||
|
{
|
||||||
|
if (CompressedStream != null)
|
||||||
|
{
|
||||||
|
CompressedStream.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
RequestContext.Response.OutputStream.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user