|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Common.Http.Dispatchers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var webRequest = (HttpWebRequest)WebRequest.Create((Uri)request.Url);
|
|
|
|
var webRequest = (HttpWebRequest)WebRequest.Create((Uri)request.Url);
|
|
|
|
|
|
|
|
|
|
|
|
if (PlatformInfo.IsMono)
|
|
|
|
if (PlatformInfo.IsMono && request.ResponseStream == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// On Mono GZipStream/DeflateStream leaks memory if an exception is thrown, use an intermediate buffer in that case.
|
|
|
|
// On Mono GZipStream/DeflateStream leaks memory if an exception is thrown, use an intermediate buffer in that case.
|
|
|
|
webRequest.AutomaticDecompression = DecompressionMethods.None;
|
|
|
|
webRequest.AutomaticDecompression = DecompressionMethods.None;
|
|
|
@ -121,19 +121,27 @@ namespace NzbDrone.Common.Http.Dispatchers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data = responseStream.ToBytes();
|
|
|
|
if (request.ResponseStream != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (PlatformInfo.IsMono && httpWebResponse.ContentEncoding == "gzip")
|
|
|
|
// A target ResponseStream was specified, write to that instead.
|
|
|
|
|
|
|
|
responseStream.CopyTo(request.ResponseStream);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (var compressedStream = new MemoryStream(data))
|
|
|
|
data = responseStream.ToBytes();
|
|
|
|
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
|
|
|
|
|
|
|
|
using (var decompressedStream = new MemoryStream())
|
|
|
|
if (PlatformInfo.IsMono && httpWebResponse.ContentEncoding == "gzip")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
gzip.CopyTo(decompressedStream);
|
|
|
|
using (var compressedStream = new MemoryStream(data))
|
|
|
|
data = decompressedStream.ToArray();
|
|
|
|
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
|
|
|
|
|
|
|
|
using (var decompressedStream = new MemoryStream())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
gzip.CopyTo(decompressedStream);
|
|
|
|
|
|
|
|
data = decompressedStream.ToArray();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
httpWebResponse.Headers.Remove("Content-Encoding");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
httpWebResponse.Headers.Remove("Content-Encoding");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|