Only do the custom decompression on mono.
This commit is contained in:
parent
76212ef908
commit
567719e6c4
|
@ -26,10 +26,19 @@ namespace NzbDrone.Common.Http.Dispatchers
|
||||||
{
|
{
|
||||||
var webRequest = (HttpWebRequest)WebRequest.Create((Uri)request.Url);
|
var webRequest = (HttpWebRequest)WebRequest.Create((Uri)request.Url);
|
||||||
|
|
||||||
|
if (PlatformInfo.IsMono)
|
||||||
|
{
|
||||||
|
// On Mono GZipStream/DeflateStream leaks memory if an exception is thrown, use an intermediate buffer in that case.
|
||||||
|
webRequest.AutomaticDecompression = DecompressionMethods.None;
|
||||||
|
webRequest.Headers.Add("Accept-Encoding", "gzip");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Deflate is not a standard and could break depending on implementation.
|
// Deflate is not a standard and could break depending on implementation.
|
||||||
// we should just stick with the more compatible Gzip
|
// we should just stick with the more compatible Gzip
|
||||||
//http://stackoverflow.com/questions/8490718/how-to-decompress-stream-deflated-with-java-util-zip-deflater-in-net
|
//http://stackoverflow.com/questions/8490718/how-to-decompress-stream-deflated-with-java-util-zip-deflater-in-net
|
||||||
webRequest.AutomaticDecompression = DecompressionMethods.None;
|
webRequest.AutomaticDecompression = DecompressionMethods.GZip;
|
||||||
|
}
|
||||||
|
|
||||||
webRequest.Method = request.Method.ToString();
|
webRequest.Method = request.Method.ToString();
|
||||||
webRequest.UserAgent = _userAgentBuilder.GetUserAgent(request.UseSimplifiedUserAgent);
|
webRequest.UserAgent = _userAgentBuilder.GetUserAgent(request.UseSimplifiedUserAgent);
|
||||||
|
@ -37,7 +46,6 @@ namespace NzbDrone.Common.Http.Dispatchers
|
||||||
webRequest.AllowAutoRedirect = false;
|
webRequest.AllowAutoRedirect = false;
|
||||||
webRequest.CookieContainer = cookies;
|
webRequest.CookieContainer = cookies;
|
||||||
|
|
||||||
webRequest.Headers.Add("Accept-Encoding", "gzip");
|
|
||||||
|
|
||||||
if (request.RequestTimeout != TimeSpan.Zero)
|
if (request.RequestTimeout != TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
|
@ -111,8 +119,7 @@ namespace NzbDrone.Common.Http.Dispatchers
|
||||||
{
|
{
|
||||||
data = responseStream.ToBytes();
|
data = responseStream.ToBytes();
|
||||||
|
|
||||||
// Do our own decompression.
|
if (PlatformInfo.IsMono && httpWebResponse.ContentEncoding == "gzip")
|
||||||
if (httpWebResponse.ContentEncoding == "gzip")
|
|
||||||
{
|
{
|
||||||
using (var compressedStream = new MemoryStream(data))
|
using (var compressedStream = new MemoryStream(data))
|
||||||
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
|
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
|
||||||
|
|
Loading…
Reference in New Issue