Skip to content

Commit

Permalink
Fix Infinite stuck #83
Browse files Browse the repository at this point in the history
  • Loading branch information
grandsilence committed May 27, 2020
1 parent 77f3b46 commit 1956dcb
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Leaf.xNet/~Http/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -976,16 +977,20 @@ private void ParseCookieFromHeader(string headerValue)

#region Загрузка тела сообщения

private IEnumerable<BytesWrapper> GetMessageBodySource()
// ReSharper disable once ReturnTypeCanBeEnumerable.Local
private BytesWrapper[] GetMessageBodySource()
{
if (_headers.ContainsKey("Content-Encoding") &&
!string.Equals(_headers["Content-Encoding"],
"utf-8", StringComparison.OrdinalIgnoreCase)) // Yandex oauth
{
return GetMessageBodySourceZip();
}

return GetMessageBodySourceStd();
bool isNonUtf8ContentEncoding =
_headers.ContainsKey("Content-Encoding") &&
// Yandex oauth fix
!string.Equals(_headers["Content-Encoding"], "utf-8", StringComparison.OrdinalIgnoreCase);

var result = isNonUtf8ContentEncoding
? GetMessageBodySourceZip()
: GetMessageBodySourceStd();

// It's a fix of response get stuck response issue #83: https://github.com/csharp-leaf/Leaf.xNet/issues/83
return result.ToArray();
}

// Загрузка обычных данных.
Expand Down

0 comments on commit 1956dcb

Please sign in to comment.