From 5a34c91469b3dd5fc344628e3eac67577a1cccc0 Mon Sep 17 00:00:00 2001 From: X-rus Date: Sun, 7 Feb 2016 10:38:54 +0600 Subject: [PATCH] 3.3.3 --- Properties/AssemblyInfo.cs | 6 +- xNet.sln | 4 +- xNet/~Http/HttpResponse.cs | 193 +------------------------------------ 3 files changed, 8 insertions(+), 195 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 743d5c4..ba76ea4 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ruslan Khuduev")] [assembly: AssemblyProduct("xNet")] -[assembly: AssemblyCopyright("Copyright © 2012-2015 Ruslan Khuduev ")] +[assembly: AssemblyCopyright("Copyright © 2012-2016 Ruslan Khuduev ")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -33,6 +33,6 @@ // Можно задать все значения или принять номер построения и номер редакции по умолчанию, // используя "*", как показано ниже: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.3.2.0")] -[assembly: AssemblyFileVersion("3.3.2.0")] +[assembly: AssemblyVersion("3.3.3.0")] +[assembly: AssemblyFileVersion("3.3.3.0")] [assembly: NeutralResourcesLanguageAttribute("ru")] diff --git a/xNet.sln b/xNet.sln index 9cf2db2..5f58d84 100644 --- a/xNet.sln +++ b/xNet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xNet", "xNet.csproj", "{5D25D06E-0D35-42EF-BBA2-D5DE6E06CD04}" EndProject diff --git a/xNet/~Http/HttpResponse.cs b/xNet/~Http/HttpResponse.cs index c0f14d4..ba1fe70 100644 --- a/xNet/~Http/HttpResponse.cs +++ b/xNet/~Http/HttpResponse.cs @@ -295,139 +295,6 @@ public override void Write(byte[] buffer, int offset, int count) #endregion } - // Поток для считывания тела сообщения. - private sealed class HttpResponseStream : Stream - { - #region Поля (закрытые) - - private Stream _baseStream; - private ReceiverHelper _receiverHelper; - private Action _endWrite; - - #endregion - - - #region Свойства (открытые) - - public override bool CanRead - { - get - { - return true; - } - } - - public override bool CanSeek - { - get - { - return false; - } - } - - public override bool CanTimeout - { - get - { - return false; - } - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override long Length - { - get - { - throw new NotSupportedException(); - } - } - - public override long Position - { - get - { - throw new NotSupportedException(); - } - set - { - throw new NotSupportedException(); - } - } - - #endregion - - - public HttpResponseStream(Stream baseStream, - ReceiverHelper receiverHelper, Action endWrite) - { - _baseStream = baseStream; - _receiverHelper = receiverHelper; - _endWrite = endWrite; - } - - - #region Методы (открытые) - - public override void Flush() - { - _baseStream.Flush(); - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - int bytesRead; - - try - { - if (_receiverHelper.HasData) - { - bytesRead = _receiverHelper.Read(buffer, offset, count); - } - else - { - bytesRead = _baseStream.Read(buffer, offset, count); - } - } - catch (Exception ex) - { - _endWrite(ex); - - throw ex; - } - - if (bytesRead == 0) - { - _endWrite(null); - } - - return bytesRead; - } - - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - - #endregion - } - #endregion @@ -877,59 +744,6 @@ public void ToFile(string path) MessageBodyLoaded = true; } - /// - /// Возвращает поток тела сообщения. - /// - /// >Если тело сообщения отсутствует, или оно уже было загружено, то будет возвращено значение . - /// Вызов метода из ошибочного ответа. - /// Ошибка при работе с HTTP-протоколом. - public Stream ToStream() - { - #region Проверка состояния - - if (HasError) - { - throw new InvalidOperationException( - Resources.InvalidOperationException_HttpResponse_HasError); - } - - #endregion - - if (MessageBodyLoaded) - { - return null; - } - - var stream = new HttpResponseStream(_request.ClientStream, _receiverHelper, (ex) => - { - if (ex != null) - { - HasError = true; - - if (ex is IOException || ex is InvalidOperationException) - { - throw NewHttpException(Resources.HttpException_FailedReceiveMessageBody, ex); - } - - throw ex; - } - - if (ConnectionClosed()) - { - _request.Dispose(); - } - - MessageBodyLoaded = true; - }); - - if (_headers.ContainsKey("Content-Encoding")) - { - return GetZipStream(stream); - } - - return stream; - } - /// /// Загружает тело сообщения и возвращает его в виде потока байтов из памяти. /// @@ -983,7 +797,7 @@ public MemoryStream ToMemoryStream() } MessageBodyLoaded = true; - + memoryStream.Position = 0; return memoryStream; } @@ -1177,7 +991,6 @@ internal long LoadResponse(HttpMethod method) try { ReceiveStartingLine(); - ReceiveHeaders(); RedirectAddress = GetLocation(); @@ -1843,9 +1656,9 @@ private Encoding GetCharacterSet() try { - return Encoding.GetEncoding(header); + return Encoding.GetEncoding(charset.Value); } - catch (ArgumentException) + catch (ArgumentException ex) { return _request.CharacterSet ?? Encoding.Default; }