Skip to content

Commit 1956dcb

Browse files
committed
Fix Infinite stuck #83
1 parent 77f3b46 commit 1956dcb

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Leaf.xNet/~Http/HttpResponse.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.IO.Compression;
5+
using System.Linq;
56
using System.Text;
67
using System.Text.RegularExpressions;
78
using System.Threading;
@@ -976,16 +977,20 @@ private void ParseCookieFromHeader(string headerValue)
976977

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

979-
private IEnumerable<BytesWrapper> GetMessageBodySource()
980+
// ReSharper disable once ReturnTypeCanBeEnumerable.Local
981+
private BytesWrapper[] GetMessageBodySource()
980982
{
981-
if (_headers.ContainsKey("Content-Encoding") &&
982-
!string.Equals(_headers["Content-Encoding"],
983-
"utf-8", StringComparison.OrdinalIgnoreCase)) // Yandex oauth
984-
{
985-
return GetMessageBodySourceZip();
986-
}
987-
988-
return GetMessageBodySourceStd();
983+
bool isNonUtf8ContentEncoding =
984+
_headers.ContainsKey("Content-Encoding") &&
985+
// Yandex oauth fix
986+
!string.Equals(_headers["Content-Encoding"], "utf-8", StringComparison.OrdinalIgnoreCase);
987+
988+
var result = isNonUtf8ContentEncoding
989+
? GetMessageBodySourceZip()
990+
: GetMessageBodySourceStd();
991+
992+
// It's a fix of response get stuck response issue #83: https://github.com/csharp-leaf/Leaf.xNet/issues/83
993+
return result.ToArray();
989994
}
990995

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

0 commit comments

Comments
 (0)