|
|
|
@ -26,18 +26,26 @@ namespace NzbDrone.Common.Http.Dispatchers
|
|
|
|
|
{
|
|
|
|
|
var webRequest = (HttpWebRequest)WebRequest.Create((Uri)request.Url);
|
|
|
|
|
|
|
|
|
|
// Deflate is not a standard and could break depending on implementation.
|
|
|
|
|
// 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
|
|
|
|
|
webRequest.AutomaticDecompression = DecompressionMethods.None;
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
// 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
|
|
|
|
|
webRequest.AutomaticDecompression = DecompressionMethods.GZip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webRequest.Method = request.Method.ToString();
|
|
|
|
|
webRequest.UserAgent = _userAgentBuilder.GetUserAgent(request.UseSimplifiedUserAgent);
|
|
|
|
|
webRequest.KeepAlive = request.ConnectionKeepAlive;
|
|
|
|
|
webRequest.AllowAutoRedirect = false;
|
|
|
|
|
webRequest.CookieContainer = cookies;
|
|
|
|
|
|
|
|
|
|
webRequest.Headers.Add("Accept-Encoding", "gzip");
|
|
|
|
|
|
|
|
|
|
if (request.RequestTimeout != TimeSpan.Zero)
|
|
|
|
|
{
|
|
|
|
@ -111,8 +119,7 @@ namespace NzbDrone.Common.Http.Dispatchers
|
|
|
|
|
{
|
|
|
|
|
data = responseStream.ToBytes();
|
|
|
|
|
|
|
|
|
|
// Do our own decompression.
|
|
|
|
|
if (httpWebResponse.ContentEncoding == "gzip")
|
|
|
|
|
if (PlatformInfo.IsMono && httpWebResponse.ContentEncoding == "gzip")
|
|
|
|
|
{
|
|
|
|
|
using (var compressedStream = new MemoryStream(data))
|
|
|
|
|
using (var gzip = new GZipStream(compressedStream, CompressionMode.Decompress))
|
|
|
|
|