Added DisposeResponseStream method to BaseHandler

pull/702/head
LukePulverenti Luke Pulverenti luke pulverenti 13 years ago
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…
Cancel
Save