From 79093d5bf5910f8ebae5c0421b9f0d1d4da2e22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:01:09 +0200 Subject: [PATCH 01/55] Add response headers in HttpException --- Tiny.RestClient/Exceptions/HttpException.cs | 13 ++++++++++++- Tiny.RestClient/Tiny.RestClient.csproj | 6 +++--- Tiny.RestClient/TinyRestClient.cs | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Tiny.RestClient/Exceptions/HttpException.cs b/Tiny.RestClient/Exceptions/HttpException.cs index 81d2c38..592df87 100644 --- a/Tiny.RestClient/Exceptions/HttpException.cs +++ b/Tiny.RestClient/Exceptions/HttpException.cs @@ -19,14 +19,16 @@ public class HttpException : TinyRestClientException /// The headers of the request /// The content. /// The status code. + /// The headers of response /// The ex. - public HttpException( + internal HttpException( Uri uri, string verb, string reasonPhrase, HttpRequestHeaders headers, string content, HttpStatusCode statusCode, + HttpResponseHeaders responseHeaders, Exception ex) : base($"Response status code does not indicate success. Url : {uri.ToString()}, Verb : {verb}, StatusCode : {statusCode}, ReasonPhrase : {reasonPhrase}", ex) { @@ -36,6 +38,7 @@ public HttpException( StatusCode = statusCode; ReasonPhrase = reasonPhrase; Headers = headers; + ResponseHeaders = responseHeaders; } /// @@ -78,6 +81,14 @@ public HttpException( /// public string Content { get; private set; } + /// + /// Gets the response headers of sended request + /// + /// + /// The verb. + /// + public HttpResponseHeaders ResponseHeaders { get; private set; } + /// /// Gets the status code. /// diff --git a/Tiny.RestClient/Tiny.RestClient.csproj b/Tiny.RestClient/Tiny.RestClient.csproj index 9a1bbad..20509fe 100644 --- a/Tiny.RestClient/Tiny.RestClient.csproj +++ b/Tiny.RestClient/Tiny.RestClient.csproj @@ -1,7 +1,7 @@  - netstandard1.1;netstandard1.2;netstandard1.3;netstandard2.0;net45;net46;net47; - 1.6.1 + netstandard1.1;netstandard1.2;netstandard1.3;netstandard2.0;net45;net46;net47 + 1.6.2 Copyright © Jérôme Giacomini 2018 en Tiny.RestClient @@ -36,7 +36,7 @@ https://github.com/jgiacomini/Tiny.RestClient.git git 3.0.3 - See release notes at https://github.com/jgiacomini/Tiny.RestClient/blob/1.6.1/RELEASE-NOTES.md + See release notes at https://github.com/jgiacomini/Tiny.RestClient/blob/1.6.2/RELEASE-NOTES.md true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index 3faff76..61593ed 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -817,6 +817,7 @@ private async Task HandleResponseAsync( response.RequestMessage.Headers, content, response.StatusCode, + response.Headers, ex); throw newEx; From e5252f8d22801aee71b5877c0bb3a4e43427ccde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:04:02 +0200 Subject: [PATCH 02/55] Update RELEASE-NOTES.md --- RELEASE-NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index c358f95..96e7c63 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,8 @@ # Release notes +## 1.6.2 +* Now HttpException expose the headers of the response +* Constructor of HttpException is now internal + ## 1.6.1 * Fix patch request which sent patch verb in lowercase From c3444d5768ac739379ebd0bb33eaf9c874aead47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:09:17 +0200 Subject: [PATCH 03/55] Update stylecop --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8bd9da3..3557c72 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -13,7 +13,7 @@ - + From 99465462bfbc5678601cb3ff6c41314b440f7cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:14:51 +0200 Subject: [PATCH 04/55] Update nuget packages --- Tests/Tiny.RestClient.ForTest.Api/Startup.cs | 4 ++-- .../Tiny.RestClient.ForTest.Api.csproj | 4 ++-- .../Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Tests/Tiny.RestClient.ForTest.Api/Startup.cs b/Tests/Tiny.RestClient.ForTest.Api/Startup.cs index 58c0294..9f05233 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Startup.cs +++ b/Tests/Tiny.RestClient.ForTest.Api/Startup.cs @@ -26,7 +26,7 @@ public void ConfigureServices(IServiceCollection services) services.AddResponseCompression(o => { - o.Providers.Add(new BrotliCompressionProvider()); + o.Providers.Add(new CompressionProvider.BrotliCompressionProvider()); o.Providers.Add(new DeflateCompressionProvider()); o.EnableForHttps = true; }); @@ -37,7 +37,7 @@ public void ConfigureServices(IServiceCollection services) options.RespectBrowserAcceptHeader = true; options.InputFormatters.Add(new XmlSerializerInputFormatter(options)); options.OutputFormatters.Add(new XmlSerializerOutputFormatter()); - }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj index 1bc28af..e4b425e 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj +++ b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj @@ -1,11 +1,11 @@  - netcoreapp2.1 + netcoreapp2.2 - + diff --git a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj index d487ec1..4ff3bc3 100644 --- a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj +++ b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj @@ -1,16 +1,16 @@  - netcoreapp2.1 + netcoreapp2.2 false - - - - + + + + From 46a5666dedd0c734f22853cfecfb672c935bb55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:18:46 +0200 Subject: [PATCH 05/55] small fixes --- Tiny.RestClient/TinyRestClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index 61593ed..312c249 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -223,6 +223,7 @@ internal async Task ExecuteAsync( { if (stream == null || stream.CanRead == false) { + // TODO : throw an exception ? return default; } @@ -488,7 +489,7 @@ private async Task GetSerializedContentAsync(IToSerializeContent co serializer = content.Serializer; } - string serializedString = null; + string serializedString; try { serializedString = content.GetSerializedString(serializer, Settings.Encoding); @@ -559,7 +560,6 @@ private Uri BuildRequestUri(string route, Dictionary queryParame if (queryParameters != null && queryParameters.Any()) { - var last = queryParameters.Last(); stringBuilder.Append("?"); for (int i = 0; i < queryParameters.Count; i++) { From 6b6cf167b677a72f87cf79f028e37a520e83d2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:20:31 +0200 Subject: [PATCH 06/55] remove useless affectation --- Tiny.RestClient/TinyRestClient.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index 312c249..b2bd13a 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -729,8 +729,7 @@ private async Task ReadResponseAsync( CancellationToken cancellationToken) { await HandleResponseAsync(response, responseHeader, eTagContainer, cancellationToken).ConfigureAwait(false); - - Stream stream = null; + Stream stream; if (eTagContainer != null && response.StatusCode == HttpStatusCode.NotModified) { stream = await eTagContainer.GetDataAsync(response.RequestMessage.RequestUri, cancellationToken).ConfigureAwait(false); From dfe5d36a2c221f184f08c8fdb7356289f415e8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:21:48 +0200 Subject: [PATCH 07/55] fix identation --- .../Controllers/FileController.cs | 2 +- .../Listener/DebugListener/DebugListener.cs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/Tiny.RestClient.ForTest.Api/Controllers/FileController.cs b/Tests/Tiny.RestClient.ForTest.Api/Controllers/FileController.cs index e754e73..c587b36 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Controllers/FileController.cs +++ b/Tests/Tiny.RestClient.ForTest.Api/Controllers/FileController.cs @@ -14,7 +14,7 @@ public async Task One() { using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { - var result = await reader.ReadToEndAsync(); + var result = await reader.ReadToEndAsync(); return result.TrimEnd(); } diff --git a/Tiny.RestClient/Listener/DebugListener/DebugListener.cs b/Tiny.RestClient/Listener/DebugListener/DebugListener.cs index 8204f28..bd5854b 100644 --- a/Tiny.RestClient/Listener/DebugListener/DebugListener.cs +++ b/Tiny.RestClient/Listener/DebugListener/DebugListener.cs @@ -46,7 +46,7 @@ public Task OnFailedToReceiveResponseAsync(Uri uri, HttpMethod httpMethod, Excep } /// - public Task OnReceivedResponseAsync(Uri uri, HttpMethod httpMethod, HttpResponseMessage response, TimeSpan? elapsedTime, CancellationToken cancellationToken) + public Task OnReceivedResponseAsync(Uri uri, HttpMethod httpMethod, HttpResponseMessage response, TimeSpan? elapsedTime, CancellationToken cancellationToken) { if (elapsedTime.HasValue) { @@ -65,17 +65,17 @@ public Task OnReceivedResponseAsync(Uri uri, HttpMethod httpMethod, HttpResponse } /// - public Task OnSendingRequestAsync(Uri uri, HttpMethod httpMethod, HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) - { + public Task OnSendingRequestAsync(Uri uri, HttpMethod httpMethod, HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken) + { Debug.WriteLine($"Sending Method = {httpMethod}, Uri = {uri}"); #if COMPLETED_TASK_NOT_SUPPORTED return TaskHelper.CompletedTask; #else return Task.CompletedTask; #endif - } + } - private string ToReadableString(TimeSpan span) + private string ToReadableString(TimeSpan span) { // TODO : rewrite this code bool addComa = false; From 0265c33ff50222d5e08f1c6e539960adea8d84b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:25:32 +0200 Subject: [PATCH 08/55] fix warning --- .../Tiny.RestClient.ForTest.Api.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj index e4b425e..d0c5150 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj +++ b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj @@ -5,7 +5,7 @@ - + From 9a5d461f0eca03dc0a6100de8b55476176a87ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:40:21 +0200 Subject: [PATCH 09/55] Add new tests --- .../Controllers/HeaderTestController.cs | 18 +++++++++++ .../HttpExceptionTests.cs | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs create mode 100644 Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs diff --git a/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs b/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs new file mode 100644 index 0000000..7a88b5e --- /dev/null +++ b/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace Tiny.RestClient.ForTest.Api.Controllers +{ + public class HeaderTestController : Controller + { + public IActionResult Get() + { + Response.Headers.Add("CustomHeader", "CustomValue"); + + return BadRequest(); + } + } +} \ No newline at end of file diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs new file mode 100644 index 0000000..b17e699 --- /dev/null +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -0,0 +1,31 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace Tiny.RestClient.Tests +{ + [TestClass] + public class HttpExceptionTests : BaseTest + { + [TestMethod] + public async Task CheckIfHttpExceptionReadHeaders() + { + bool exceptionThrowed = false; + var client = GetClient(); + try + { + await client.GetRequest("HeaderTest/Get").ExecuteAsync(); + } + catch (HttpException ex) + { + exceptionThrowed = true; + + Assert.IsTrue(ex.ResponseHeaders.Contains("CustomHeader"), "An header name 'CustomHeader' must be present in response"); + } + + Assert.IsTrue(exceptionThrowed, $"An {nameof(HttpException)} must be throwed"); + } + } +} From eec36b88433fd01f06275e0265b357da98c0e465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:51:42 +0200 Subject: [PATCH 10/55] downgrad nuget package for unit test work --- Tests/Tiny.RestClient.ForTest.Api/Startup.cs | 2 +- .../Tiny.RestClient.ForTest.Api.csproj | 2 +- Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/Tiny.RestClient.ForTest.Api/Startup.cs b/Tests/Tiny.RestClient.ForTest.Api/Startup.cs index 9f05233..d4db2e6 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Startup.cs +++ b/Tests/Tiny.RestClient.ForTest.Api/Startup.cs @@ -37,7 +37,7 @@ public void ConfigureServices(IServiceCollection services) options.RespectBrowserAcceptHeader = true; options.InputFormatters.Add(new XmlSerializerInputFormatter(options)); options.OutputFormatters.Add(new XmlSerializerOutputFormatter()); - }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj index d0c5150..6d2a08b 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj +++ b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp2.1 diff --git a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj index 4ff3bc3..3bc09fb 100644 --- a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj +++ b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj @@ -7,10 +7,10 @@ - - - - + + + + From 9b00f04f3b742e0543313a90ba47228433bb961a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:54:56 +0200 Subject: [PATCH 11/55] downgrad version of .netcore in tests --- Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj index 3bc09fb..bebc0c1 100644 --- a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj +++ b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp2.1 false From 60b6e7088e7854e3199c9ff213a51504e3a7806c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 17:56:30 +0200 Subject: [PATCH 12/55] change version of nugets on test project --- Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj index bebc0c1..d487ec1 100644 --- a/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj +++ b/Tests/Tiny.RestClient.Tests/Tiny.RestClient.Tests.csproj @@ -7,10 +7,10 @@ - - - - + + + + From eae3a122c99acca219c9dfa67ceb23f3a3a6d85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 19:43:16 +0200 Subject: [PATCH 13/55] Fix tests --- .../Controllers/HeaderTestController.cs | 18 ------------------ .../Tiny.RestClient.ForTest.Api.csproj | 2 +- .../HttpExceptionTests.cs | 5 +++-- 3 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs diff --git a/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs b/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs deleted file mode 100644 index 7a88b5e..0000000 --- a/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeaderTestController.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -namespace Tiny.RestClient.ForTest.Api.Controllers -{ - public class HeaderTestController : Controller - { - public IActionResult Get() - { - Response.Headers.Add("CustomHeader", "CustomValue"); - - return BadRequest(); - } - } -} \ No newline at end of file diff --git a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj index 6d2a08b..1bc28af 100644 --- a/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj +++ b/Tests/Tiny.RestClient.ForTest.Api/Tiny.RestClient.ForTest.Api.csproj @@ -5,7 +5,7 @@ - + diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index b17e699..24ca502 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -16,13 +16,14 @@ public async Task CheckIfHttpExceptionReadHeaders() var client = GetClient(); try { - await client.GetRequest("HeaderTest/Get").ExecuteAsync(); + // Call an api not found (the Etag header is present in all responses on this server) + await client.GetRequest("APIWhichNotExists").ExecuteAsync(); } catch (HttpException ex) { exceptionThrowed = true; - Assert.IsTrue(ex.ResponseHeaders.Contains("CustomHeader"), "An header name 'CustomHeader' must be present in response"); + Assert.IsTrue(ex.ResponseHeaders.Contains("ETag"), "An header name 'ETag' must be present in response"); } Assert.IsTrue(exceptionThrowed, $"An {nameof(HttpException)} must be throwed"); From 19cab9d790b093e9f7c5e2706c20c11ee459f6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 19:50:08 +0200 Subject: [PATCH 14/55] small change --- Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index 24ca502..d5f87d5 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -16,7 +16,7 @@ public async Task CheckIfHttpExceptionReadHeaders() var client = GetClient(); try { - // Call an api not found (the Etag header is present in all responses on this server) + // Call an api not found (the ETag header is present in all responses on this server) await client.GetRequest("APIWhichNotExists").ExecuteAsync(); } catch (HttpException ex) From 551f784cf2fa39032a692a649508db3b2ffd447a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 19:51:49 +0200 Subject: [PATCH 15/55] typo --- Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index d5f87d5..986c2cd 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -23,7 +23,7 @@ public async Task CheckIfHttpExceptionReadHeaders() { exceptionThrowed = true; - Assert.IsTrue(ex.ResponseHeaders.Contains("ETag"), "An header name 'ETag' must be present in response"); + Assert.IsTrue(ex.ResponseHeaders.Contains("ETag"), "An header name 'ETag' must be present in response."); } Assert.IsTrue(exceptionThrowed, $"An {nameof(HttpException)} must be throwed"); From 2bb6ea8e4cb514c4ab9409c207bdb803b6437c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:14:56 +0200 Subject: [PATCH 16/55] fixComment --- Tiny.RestClient/Compression/Compressions.cs | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Tiny.RestClient/Compression/Compressions.cs b/Tiny.RestClient/Compression/Compressions.cs index 20026ef..079db01 100644 --- a/Tiny.RestClient/Compression/Compressions.cs +++ b/Tiny.RestClient/Compression/Compressions.cs @@ -4,7 +4,7 @@ namespace Tiny.RestClient { /// - /// Represent headers of requests + /// Represent headers of requests. /// public class Compressions : IEnumerable> { @@ -16,9 +16,9 @@ internal Compressions() } /// - /// Add header + /// Add header. /// - /// header name + /// header name. public void Add(ICompression compression) { if (!_compressions.ContainsKey(compression.ContentEncoding)) @@ -32,9 +32,9 @@ public void Add(ICompression compression) } /// - /// Removes the compression + /// Removes the compression. /// - /// item to remove + /// item to remove. /// public bool Remove(ICompression compression) { @@ -42,20 +42,20 @@ public bool Remove(ICompression compression) } /// - /// Determines whether the contains the specified compression system + /// Determines whether the contains the specified compression system. /// - /// content encoding - /// returns true if contains an element with this contentEncoding otherwise false + /// content encoding. + /// returns true if contains an element with this contentEncoding otherwise false. public bool Contains(string contentEncoding) { return _compressions.ContainsKey(contentEncoding); } /// - /// Gets or sets Compression system + /// Gets or sets Compression system. /// - /// content encoding key - /// return compression system + /// content encoding key. + /// return compression system. public ICompression this[string contentEncoding] { get @@ -81,7 +81,7 @@ IEnumerator IEnumerable.GetEnumerator() /// /// Removes all system - /// /// + /// ///. public void Clear() { _compressions.Clear(); From 7e3cd27895d48dcf3c8facf2829c4a998c5b4b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:11 +0200 Subject: [PATCH 17/55] fix comment --- Tiny.RestClient/Compression/DeflateCompression.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Compression/DeflateCompression.cs b/Tiny.RestClient/Compression/DeflateCompression.cs index d42872f..8483292 100644 --- a/Tiny.RestClient/Compression/DeflateCompression.cs +++ b/Tiny.RestClient/Compression/DeflateCompression.cs @@ -6,7 +6,7 @@ namespace Tiny.RestClient { /// - /// Gzip compression + /// Gzip compression. /// public class DeflateCompression : ICompression { From bbc5c581a1985d5fb3cc060754481a52411d4155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:21 +0200 Subject: [PATCH 18/55] fixComment --- Tiny.RestClient/Compression/GzipCompression.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Compression/GzipCompression.cs b/Tiny.RestClient/Compression/GzipCompression.cs index 7ff0f6b..d95cb02 100644 --- a/Tiny.RestClient/Compression/GzipCompression.cs +++ b/Tiny.RestClient/Compression/GzipCompression.cs @@ -6,7 +6,7 @@ namespace Tiny.RestClient { /// - /// Gzip compression + /// Gzip compression. /// public class GzipCompression : ICompression { From 647536623c5fbe446678e1edf650f22ea8419657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:28 +0200 Subject: [PATCH 19/55] fix comment --- Tiny.RestClient/Compression/ICompression.cs | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Tiny.RestClient/Compression/ICompression.cs b/Tiny.RestClient/Compression/ICompression.cs index b68775c..1a66585 100644 --- a/Tiny.RestClient/Compression/ICompression.cs +++ b/Tiny.RestClient/Compression/ICompression.cs @@ -5,36 +5,36 @@ namespace Tiny.RestClient { /// - /// Represent a way to manage compression / decompression + /// Represent a way to manage compression / decompression. /// public interface ICompression { /// - /// Gets the content encoding of compression + /// Gets the content encoding of compression. /// string ContentEncoding { get; } /// - /// Gets or sets if the compression system add accept headers when the request is sended + /// Gets or sets if the compression system add accept headers when the request is sended. /// bool AddAcceptEncodingHeader { get; set; } /// /// Compresses the stream. /// - /// the stream to compress - /// the buffer size to use - /// the cancellation token - /// returns stream compressed + /// the stream to compress. + /// the buffer size to use. + /// the cancellation token. + /// returns stream compressed. Task CompressAsync(Stream stream, int bufferSize, CancellationToken cancellationToken); /// /// Decompresses the stream. /// - /// the stream to decompress - /// the buffer size to use - /// the cancellation token - /// returns stream compressed + /// the stream to decompress. + /// the buffer size to use. + /// the cancellation token. + /// returns stream compressed. Task DecompressAsync(Stream stream, int bufferSize, CancellationToken cancellationToken); } } From e1f772354531a78e4c8710a8663a03e7dd9d6681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:36 +0200 Subject: [PATCH 20/55] fix comment --- Tiny.RestClient/ETag/ETagFileContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/ETag/ETagFileContainer.cs b/Tiny.RestClient/ETag/ETagFileContainer.cs index eaf3aa8..0c7f018 100644 --- a/Tiny.RestClient/ETag/ETagFileContainer.cs +++ b/Tiny.RestClient/ETag/ETagFileContainer.cs @@ -9,7 +9,7 @@ namespace Tiny.RestClient { /// - /// Class which store data of entity in a directory + /// Class which store data of entity in a directory. /// public class ETagFileContainer : IETagContainer { @@ -19,7 +19,7 @@ public class ETagFileContainer : IETagContainer /// /// Initializes a new instance of the class. /// - /// the path of the directory which will store the data + /// the path of the directory which will store the data. public ETagFileContainer(string pathOfDirectoryContainer) { _pathOfDirectoryContainer = pathOfDirectoryContainer ?? throw new ArgumentNullException(nameof(pathOfDirectoryContainer)); From 358e6e28a2996a7e80b60f10f1cd0d49f80a5545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:45 +0200 Subject: [PATCH 21/55] fix comment --- Tiny.RestClient/ETag/IETagContainer.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tiny.RestClient/ETag/IETagContainer.cs b/Tiny.RestClient/ETag/IETagContainer.cs index bdfcb9f..517d5e8 100644 --- a/Tiny.RestClient/ETag/IETagContainer.cs +++ b/Tiny.RestClient/ETag/IETagContainer.cs @@ -6,32 +6,32 @@ namespace Tiny.RestClient { /// - /// Entity Tag container + /// Entity Tag container. /// public interface IETagContainer { /// /// Get the existing ETag. /// - /// the uri + /// the uri. /// The cancellation token. /// return the etag if found. If not return null. Task GetExistingETagAsync(Uri uri, CancellationToken cancellationToken); /// - /// Get data of specific uri + /// Get data of specific uri. /// - /// the uri + /// the uri. /// The cancellation token. - /// return the of data + /// return the of data. Task GetDataAsync(Uri uri, CancellationToken cancellationToken); /// - /// S + /// S. /// - /// the uri - /// the etag of data - /// of data to store + /// the uri. + /// the etag of data. + /// of data to store. /// The cancellation token. /// Task SaveDataAsync(Uri uri, string etag, Stream stream, CancellationToken cancellationToken); From 716ea14a357dd16848a9918e74adf1695d2107a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:15:53 +0200 Subject: [PATCH 22/55] fix comment --- Tiny.RestClient/Exceptions/HttpException.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tiny.RestClient/Exceptions/HttpException.cs b/Tiny.RestClient/Exceptions/HttpException.cs index 592df87..a18f279 100644 --- a/Tiny.RestClient/Exceptions/HttpException.cs +++ b/Tiny.RestClient/Exceptions/HttpException.cs @@ -5,7 +5,7 @@ namespace Tiny.RestClient { /// - /// A + /// A . /// /// public class HttpException : TinyRestClientException @@ -16,10 +16,10 @@ public class HttpException : TinyRestClientException /// The URL. /// The verb. /// The reason phrase. - /// The headers of the request + /// The headers of the request. /// The content. /// The status code. - /// The headers of response + /// The headers of response. /// The ex. internal HttpException( Uri uri, @@ -50,7 +50,7 @@ internal HttpException( public string Verb { get; private set; } /// - /// Gets the headers of sended request + /// Gets the headers of sended request. /// /// /// The verb. @@ -82,7 +82,7 @@ internal HttpException( public string Content { get; private set; } /// - /// Gets the response headers of sended request + /// Gets the response headers of sended request. /// /// /// The verb. From 6c436b5f62b11450ad5d6982944cb76db16f8e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:09 +0200 Subject: [PATCH 23/55] fix comment --- .../KebabCasePropertyNamesContractResolver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/Formatters/Json/ContractResolver/KebabCasePropertyNamesContractResolver.cs b/Tiny.RestClient/Formatters/Json/ContractResolver/KebabCasePropertyNamesContractResolver.cs index 65f8548..030776c 100644 --- a/Tiny.RestClient/Formatters/Json/ContractResolver/KebabCasePropertyNamesContractResolver.cs +++ b/Tiny.RestClient/Formatters/Json/ContractResolver/KebabCasePropertyNamesContractResolver.cs @@ -1,13 +1,13 @@ namespace Tiny.RestClient.Json { /// - /// Allow SnakeCase (or name also Spinal case) resolve of property (property-name become PropertyName) + /// Allow SnakeCase (or name also Spinal case) resolve of property (property-name become PropertyName). /// /// public class KebabCasePropertyNamesContractResolver : SeparatorPropertyNamesContractResolver { /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// public KebabCasePropertyNamesContractResolver() : base('-') From b56a31aef9f8bb125e6fadf375456e976da0dabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:19 +0200 Subject: [PATCH 24/55] fix comment --- .../SeparatorPropertyNamesContractResolver.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tiny.RestClient/Formatters/Json/ContractResolver/SeparatorPropertyNamesContractResolver.cs b/Tiny.RestClient/Formatters/Json/ContractResolver/SeparatorPropertyNamesContractResolver.cs index f83e9ac..bd0d9e4 100644 --- a/Tiny.RestClient/Formatters/Json/ContractResolver/SeparatorPropertyNamesContractResolver.cs +++ b/Tiny.RestClient/Formatters/Json/ContractResolver/SeparatorPropertyNamesContractResolver.cs @@ -5,25 +5,25 @@ namespace Tiny.RestClient.Json { /// - /// Allow a custom separator to resolve of property (propertySEPARATORname become PropertyName) + /// Allow a custom separator to resolve of property (propertySEPARATORname become PropertyName). /// public class SeparatorPropertyNamesContractResolver : DefaultContractResolver { private readonly string _separator; /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// - /// separator bewteen words + /// separator bewteen words. public SeparatorPropertyNamesContractResolver(char separator) { _separator = separator.ToString(); } /// - /// Resolves a property name to a delimited name + /// Resolves a property name to a delimited name. /// - /// property name to resolve + /// property name to resolve. /// protected override string ResolvePropertyName(string propertyName) { From f80117dfe5d997ec6f2c33aff1828dbe5ca82548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:31 +0200 Subject: [PATCH 25/55] fix comment --- .../SnakeCasePropertyNamesContractResolver.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/Formatters/Json/ContractResolver/SnakeCasePropertyNamesContractResolver.cs b/Tiny.RestClient/Formatters/Json/ContractResolver/SnakeCasePropertyNamesContractResolver.cs index 543ecbd..41d9345 100644 --- a/Tiny.RestClient/Formatters/Json/ContractResolver/SnakeCasePropertyNamesContractResolver.cs +++ b/Tiny.RestClient/Formatters/Json/ContractResolver/SnakeCasePropertyNamesContractResolver.cs @@ -1,13 +1,13 @@ namespace Tiny.RestClient.Json { /// - /// Allow snake case resolve of property (property_name become PropertyName) + /// Allow snake case resolve of property (property_name become PropertyName). /// /// public class SnakeCasePropertyNamesContractResolver : SeparatorPropertyNamesContractResolver { /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// public SnakeCasePropertyNamesContractResolver() : base('_') From 20ff5ad214f7c1d9190550a4cf5f8d977ea2bbe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:37 +0200 Subject: [PATCH 26/55] fix comment --- Tiny.RestClient/Formatters/Json/JsonFormatter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tiny.RestClient/Formatters/Json/JsonFormatter.cs b/Tiny.RestClient/Formatters/Json/JsonFormatter.cs index 5722ca8..88ccfbc 100644 --- a/Tiny.RestClient/Formatters/Json/JsonFormatter.cs +++ b/Tiny.RestClient/Formatters/Json/JsonFormatter.cs @@ -9,13 +9,13 @@ namespace Tiny.RestClient { /// - /// Serializes and deserializes objects into and from the JSON format using the Newtonsoft.Json.JsonSerializer + /// Serializes and deserializes objects into and from the JSON format using the Newtonsoft.Json.JsonSerializer. /// /// public class JsonFormatter : IFormatter { /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// public JsonFormatter() { @@ -23,12 +23,12 @@ public JsonFormatter() } /// - /// Gets the instance of JsonSerializer + /// Gets the instance of JsonSerializer. /// public JsonSerializer JsonSerializer { get; } /// - /// Enable snake case for properties mapping. A property "PropertyName" will become "property_name" + /// Enable snake case for properties mapping. A property "PropertyName" will become "property_name". /// public void UseSnakeCase() { @@ -36,7 +36,7 @@ public void UseSnakeCase() } /// - /// Enable camel case for properties mapping. A property "PropertyName" will become "propertyName" + /// Enable camel case for properties mapping. A property "PropertyName" will become "propertyName". /// public void UseCamelCase() { @@ -44,7 +44,7 @@ public void UseCamelCase() } /// - /// Enable kebab case (also named spinal case) for properties mapping. A property "PropertyName" will become "property-name" + /// Enable kebab case (also named spinal case) for properties mapping. A property "PropertyName" will become "property-name". /// public void UseKebabCase() { From 290226c9618d36b4512688498ae6ef56f809dd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:46 +0200 Subject: [PATCH 27/55] fix comment --- Tiny.RestClient/Formatters/Xml/XmlFormatter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/Formatters/Xml/XmlFormatter.cs b/Tiny.RestClient/Formatters/Xml/XmlFormatter.cs index 147c172..252e14c 100644 --- a/Tiny.RestClient/Formatters/Xml/XmlFormatter.cs +++ b/Tiny.RestClient/Formatters/Xml/XmlFormatter.cs @@ -13,7 +13,7 @@ namespace Tiny.RestClient public class XmlFormatter : IFormatter { /// - /// Initializes a new instance of the + /// Initializes a new instance of the . /// public XmlFormatter() { @@ -37,7 +37,7 @@ public IEnumerable SupportedMediaTypes } /// - /// Gets the instance of WriterSettings + /// Gets the instance of WriterSettings. /// public XmlWriterSettings WriterSettings { get; } From 10975b4ba0fe5c355de039805f81831e496ef26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:16:55 +0200 Subject: [PATCH 28/55] fix comment --- Tiny.RestClient/Formatters/Formatters.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Tiny.RestClient/Formatters/Formatters.cs b/Tiny.RestClient/Formatters/Formatters.cs index 48d4d76..05b3980 100644 --- a/Tiny.RestClient/Formatters/Formatters.cs +++ b/Tiny.RestClient/Formatters/Formatters.cs @@ -5,7 +5,7 @@ namespace Tiny.RestClient { /// - /// Collection of + /// Collection of . /// public class Formatters : IEnumerable { @@ -23,7 +23,7 @@ internal Formatters() } /// - /// Gets the default + /// Gets the default . /// public IFormatter Default { @@ -34,11 +34,11 @@ public IFormatter Default } /// - /// Add a formatter in the list of supported formatters + /// Add a formatter in the list of supported formatters. /// - /// Add the formatter to the list of supported formatter. The value can't be null - /// Define this formatter as default formatter - /// throw if formatter is null + /// Add the formatter to the list of supported formatter. The value can't be null. + /// Define this formatter as default formatter. + /// throw if formatter is null. public void Add(IFormatter formatter, bool isDefault) { if (formatter == null) @@ -55,12 +55,12 @@ public void Add(IFormatter formatter, bool isDefault) } /// - /// Removes a formatter in the list of supported formatters + /// Removes a formatter in the list of supported formatters. /// - /// The formatter to remove on the supported formatter list + /// The formatter to remove on the supported formatter list. /// true if item is successfully removed; otherwise, false. This method also returns false if item was not found. - /// throw if formatter is null - /// throw if the current formatter removed is the default one + /// throw if formatter is null. + /// throw if the current formatter removed is the default one. public bool Remove(IFormatter formatter) { if (formatter == null) From 63a1d1f995861618b4362779b159376b51002af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:17:01 +0200 Subject: [PATCH 29/55] fix comment --- Tiny.RestClient/Formatters/IFormatter.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tiny.RestClient/Formatters/IFormatter.cs b/Tiny.RestClient/Formatters/IFormatter.cs index caaf49f..4c5749e 100644 --- a/Tiny.RestClient/Formatters/IFormatter.cs +++ b/Tiny.RestClient/Formatters/IFormatter.cs @@ -5,18 +5,18 @@ namespace Tiny.RestClient { /// - /// Interface IFormatter + /// Interface IFormatter. /// public interface IFormatter { /// - /// Gets the default media type used to send request + /// Gets the default media type used to send request. /// /// The type of the media. string DefaultMediaType { get; } /// - /// Gets the supported media type by the serializer + /// Gets the supported media type by the serializer. /// /// The type of the media. IEnumerable SupportedMediaTypes { get; } @@ -24,7 +24,7 @@ public interface IFormatter /// /// Serializes the specified data. /// - /// Type of data serialized + /// Type of data serialized. /// The data. /// The encoding. /// System.String. @@ -36,7 +36,7 @@ public interface IFormatter /// /// The stream. /// The encoding. - /// An instance of type + /// An instance of type . T Deserialize(Stream stream, Encoding encoding); } } \ No newline at end of file From d895104bbd23aee10867f9239753b9fb33bd329d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:17:10 +0200 Subject: [PATCH 30/55] fix comment --- Tiny.RestClient/Listener/CurlListener/CurlListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Listener/CurlListener/CurlListener.cs b/Tiny.RestClient/Listener/CurlListener/CurlListener.cs index a78b780..252133b 100644 --- a/Tiny.RestClient/Listener/CurlListener/CurlListener.cs +++ b/Tiny.RestClient/Listener/CurlListener/CurlListener.cs @@ -11,7 +11,7 @@ namespace Tiny.RestClient { /// - /// A listener which will create a postMan collection/> + /// A listener which will create a postMan collection/>. /// public class CurlListener : IListener { From 9970b7df2e882e53b608b5aa9ad69be331778077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:17:54 +0200 Subject: [PATCH 31/55] fix comment --- .../Listener/CurlListener/CurlListenerExtension.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tiny.RestClient/Listener/CurlListener/CurlListenerExtension.cs b/Tiny.RestClient/Listener/CurlListener/CurlListenerExtension.cs index 22d136e..0fd6766 100644 --- a/Tiny.RestClient/Listener/CurlListener/CurlListenerExtension.cs +++ b/Tiny.RestClient/Listener/CurlListener/CurlListenerExtension.cs @@ -1,15 +1,15 @@ namespace Tiny.RestClient { /// - /// Extension to add easily curl listener + /// Extension to add easily curl listener. /// public static class CurlListenerExtension { /// - /// Add to listeners /> + /// Add to listeners />. /// - /// all listeners - /// listener created + /// all listeners. + /// listener created. public static CurlListener AddCurl(this Listeners listeners) { var listener = new CurlListener(); From 941c32aec9b809d540e2a193c7724366856b18c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:05 +0200 Subject: [PATCH 32/55] fix comment --- Tiny.RestClient/Listener/DebugListener/DebugListener.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tiny.RestClient/Listener/DebugListener/DebugListener.cs b/Tiny.RestClient/Listener/DebugListener/DebugListener.cs index bd5854b..60ffe69 100644 --- a/Tiny.RestClient/Listener/DebugListener/DebugListener.cs +++ b/Tiny.RestClient/Listener/DebugListener/DebugListener.cs @@ -10,14 +10,14 @@ namespace Tiny.RestClient { /// - /// A listener which will trace all requests with + /// A listener which will trace all requests with . /// public class DebugListener : IListener { /// /// Initializes a new instance of the class. /// - /// true if measure time + /// true if measure time. public DebugListener(bool measureTime) { MeasureTime = measureTime; From d02fc5f930f30fcdc3bdb1f37c6959dbaa811d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:11 +0200 Subject: [PATCH 33/55] fix comment --- .../Listener/DebugListener/DebugListenerExtension.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tiny.RestClient/Listener/DebugListener/DebugListenerExtension.cs b/Tiny.RestClient/Listener/DebugListener/DebugListenerExtension.cs index dec03b2..b409f26 100644 --- a/Tiny.RestClient/Listener/DebugListener/DebugListenerExtension.cs +++ b/Tiny.RestClient/Listener/DebugListener/DebugListenerExtension.cs @@ -3,15 +3,15 @@ namespace Tiny.RestClient { /// - /// Extension to add easily debug listener + /// Extension to add easily debug listener. /// public static class DebugListenerExtension { /// - /// Add to listeners /> + /// Add to listeners />. /// - /// all listeners - /// allow to measure time to this listener + /// all listeners. + /// allow to measure time to this listener. [Conditional("DEBUG")] public static void AddDebug(this Listeners listeners, bool measureTime = true) { From 404c806fd204fe0b89de95d0375323633dcf732e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:18 +0200 Subject: [PATCH 34/55] fix comment --- .../Listener/PostmanListener/PostmanListener.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tiny.RestClient/Listener/PostmanListener/PostmanListener.cs b/Tiny.RestClient/Listener/PostmanListener/PostmanListener.cs index f26139f..5825485 100644 --- a/Tiny.RestClient/Listener/PostmanListener/PostmanListener.cs +++ b/Tiny.RestClient/Listener/PostmanListener/PostmanListener.cs @@ -13,7 +13,7 @@ namespace Tiny.RestClient { /// - /// A listener which will create a postMan collection/> + /// A listener which will create a postMan collection/>. /// public class PostmanListener : IListener { @@ -22,7 +22,7 @@ public class PostmanListener : IListener /// /// Initializes a new instance of the class. /// - /// name of the postMan collection + /// name of the postMan collection. public PostmanListener(string name) { if (string.IsNullOrEmpty(name)) @@ -49,10 +49,10 @@ public PostmanListener(string name) #if !FILEINFO_NOT_SUPPORTED /// - /// Save PostManCollection to file + /// Save PostManCollection to file. /// - /// file where the collection is saved - /// return a + /// file where the collection is saved. + /// return a . public async Task SaveAsync(FileInfo fileInfo) { if (fileInfo.Exists) @@ -69,9 +69,9 @@ public async Task SaveAsync(FileInfo fileInfo) #endif /// - /// Get postman collection json data + /// Get postman collection json data. /// - /// return a post man collection json file + /// return a post man collection json file. public string GetCollectionJson() { lock (_toLock) From 4884deac7b6d0714b0c798010a30c358aa9cc6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:28 +0200 Subject: [PATCH 35/55] fix comment --- .../PostmanListener/PostmanListenerExtension.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tiny.RestClient/Listener/PostmanListener/PostmanListenerExtension.cs b/Tiny.RestClient/Listener/PostmanListener/PostmanListenerExtension.cs index a6b6807..e5fa1f3 100644 --- a/Tiny.RestClient/Listener/PostmanListener/PostmanListenerExtension.cs +++ b/Tiny.RestClient/Listener/PostmanListener/PostmanListenerExtension.cs @@ -1,16 +1,16 @@ namespace Tiny.RestClient { /// - /// Extension to add easily postman listener + /// Extension to add easily postman listener. /// public static class PostmanListenerExtension { /// - /// Add to listeners /> + /// Add to listeners />. /// - /// all listeners - /// name of the collection - /// listener created + /// all listeners. + /// name of the collection. + /// listener created. public static PostmanListener AddPostman(this Listeners listeners, string name) { var listener = new PostmanListener(name); From e63930f92de08be1610aaeb2f025ece4fd6e216c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:37 +0200 Subject: [PATCH 36/55] fix comment --- Tiny.RestClient/TinyRestClient.cs | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index b2bd13a..5705cc2 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -32,7 +32,7 @@ public class TinyRestClient /// /// Initializes a new instance of the class. /// - /// The httpclient used + /// The httpclient used. /// The server address. public TinyRestClient(HttpClient httpClient, string serverAddress) { @@ -55,7 +55,7 @@ public TinyRestClient(HttpClient httpClient, string serverAddress) #endregion /// - /// Settings of + /// Settings of . /// public RestClientSettings Settings { get; } @@ -95,9 +95,9 @@ public IRequest PostRequest(string route = null) /// /// Create a new POST request. /// - /// The content of the request - /// The formatter use to serialize the content - /// Add compresion system use to compress content + /// The content of the request. + /// The formatter use to serialize the content. + /// Add compresion system use to compress content. /// The new request. public IParameterRequest PostRequest(TContent content, IFormatter formatter = null, ICompression compression = null) { @@ -109,9 +109,9 @@ public IParameterRequest PostRequest(TContent content, IFormatter form /// Create a new POST request. /// /// The route. - /// The content of the request - /// The formatter use to serialize the content - /// Add compresion system use to compress content + /// The content of the request. + /// The formatter use to serialize the content. + /// Add compresion system use to compress content. /// The new request. public IParameterRequest PostRequest(string route, TContent content, IFormatter formatter = null, ICompression compression = null) { @@ -132,9 +132,9 @@ public IRequest PutRequest(string route = null) /// /// Create a new PUT request. /// - /// The content of the request - /// The formatter use to serialize the content - /// Add compresion system use to compress content + /// The content of the request. + /// The formatter use to serialize the content. + /// Add compresion system use to compress content. /// The new request. public IParameterRequest PutRequest(TContent content, IFormatter formatter = null, ICompression compression = null) { @@ -146,9 +146,9 @@ public IParameterRequest PutRequest(TContent content, IFormatter forma /// Create a new PUT request. /// /// The route. - /// The content of the request - /// The formatter use to serialize the content - /// Add compresion system use to compress content + /// The content of the request. + /// The formatter use to serialize the content. + /// Add compresion system use to compress content. /// The new request. public IParameterRequest PutRequest(string route, TContent content, IFormatter formatter = null, ICompression compression = null) { @@ -169,9 +169,9 @@ public IRequest PatchRequest(string route = null) /// /// Create a new PATCH request. /// - /// The content of the request - /// The serializer use to serialize it - /// Add compresion system use to compress content + /// The content of the request. + /// The serializer use to serialize it. + /// Add compresion system use to compress content. /// The new request. public IParameterRequest PatchRequest(TContent content, IFormatter serializer = null, ICompression compression = null) { @@ -183,9 +183,9 @@ public IParameterRequest PatchRequest(TContent content, IFormatter ser /// Create a new PATCH request. /// /// The route. - /// The content of the request - /// The serializer use to serialize it - /// Add compresion system use ton compress content + /// The content of the request. + /// The serializer use to serialize it. + /// Add compresion system use ton compress content. /// The new request. public IParameterRequest PatchRequest(string route, TContent content, IFormatter serializer = null, ICompression compression = null) { From 76e3d84286c1bbcf27da4c76090e9ba3e94ce713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:45 +0200 Subject: [PATCH 37/55] fix comment --- Tiny.RestClient/Listener/IListener.cs | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Tiny.RestClient/Listener/IListener.cs b/Tiny.RestClient/Listener/IListener.cs index 029ad6d..20717a6 100644 --- a/Tiny.RestClient/Listener/IListener.cs +++ b/Tiny.RestClient/Listener/IListener.cs @@ -6,45 +6,45 @@ namespace Tiny.RestClient { /// - /// Represent a request listener + /// Represent a request listener. /// public interface IListener { /// - /// Enable the measure of time between requests + /// Enable the measure of time between requests. /// bool MeasureTime { get; } /// - /// Invoked when a request is sending + /// Invoked when a request is sending. /// - /// uri of the request - /// verb of the request - /// message sended to server + /// uri of the request. + /// verb of the request. + /// message sended to server. /// The cancellation token to cancel operation. - /// A + /// A . Task OnSendingRequestAsync(Uri uri, HttpMethod httpMethod, HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken); /// - /// Invoked when received a response from server + /// Invoked when received a response from server. /// - /// uri of the request - /// verb of the request - /// response of the server - /// time ellapsed between the send of request and response of server + /// uri of the request. + /// verb of the request. + /// response of the server. + /// time ellapsed between the send of request and response of server. /// The cancellation token to cancel operation. - /// A + /// A . Task OnReceivedResponseAsync(Uri uri, HttpMethod httpMethod, HttpResponseMessage response, TimeSpan? elapsedTime, CancellationToken cancellationToken); /// - /// Invoke when a request failed to be invoked + /// Invoke when a request failed to be invoked. /// - /// uri of the request - /// verb of the request - /// exception - /// time ellapsed between the send of request and response of server (can be null if no listener measure time) + /// uri of the request. + /// verb of the request. + /// exception. + /// time ellapsed between the send of request and response of server (can be null if no listener measure time). /// The cancellation token to cancel operation. - /// A + /// A . Task OnFailedToReceiveResponseAsync(Uri uri, HttpMethod httpMethod, Exception exception, TimeSpan? elapsedTime, CancellationToken cancellationToken); } } From c41eaef0ec3b382c8e52ea3a4a27bf3b6b3b55aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:52 +0200 Subject: [PATCH 38/55] fix comment --- Tiny.RestClient/Request/Headers/Headers.cs | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Tiny.RestClient/Request/Headers/Headers.cs b/Tiny.RestClient/Request/Headers/Headers.cs index eb4c3f0..326fc82 100644 --- a/Tiny.RestClient/Request/Headers/Headers.cs +++ b/Tiny.RestClient/Request/Headers/Headers.cs @@ -7,7 +7,7 @@ namespace Tiny.RestClient { /// - /// Represent headers of requests + /// Represent headers of requests. /// public class Headers : IEnumerable>> { @@ -19,19 +19,19 @@ internal Headers() } /// - /// Add OAuth 2.0 token + /// Add OAuth 2.0 token. /// - /// token to add + /// token to add. public void AddBearer(string token) { Add("Authorization", $"Bearer {token}"); } /// - /// Add basic authentication + /// Add basic authentication. /// - /// the username - /// the password + /// the username. + /// the password. public void AddBasicAuthentication(string username, string password) { var encodedCreds = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}")); @@ -39,10 +39,10 @@ public void AddBasicAuthentication(string username, string password) } /// - /// Add header + /// Add header. /// - /// header name - /// header value + /// header name. + /// header value. public void Add(string name, string value) { List list = null; @@ -60,9 +60,9 @@ public void Add(string name, string value) } /// - /// Removes the header with specified name + /// Removes the header with specified name. /// - /// name of the header + /// name of the header. /// public bool Remove(string name) { @@ -91,10 +91,10 @@ internal void AddRange(IEnumerable>> ra } /// - /// Gets or sets header + /// Gets or sets header. /// - /// header name - /// return header's value + /// header name. + /// return header's value. public IEnumerable this[string name] { get From 63a5c0713dd372d4b69882e2b7d0d53862f24286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:19:59 +0200 Subject: [PATCH 39/55] fix comment --- Tiny.RestClient/Listener/Listeners.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Listener/Listeners.cs b/Tiny.RestClient/Listener/Listeners.cs index e8c8e92..d8efa6b 100644 --- a/Tiny.RestClient/Listener/Listeners.cs +++ b/Tiny.RestClient/Listener/Listeners.cs @@ -9,7 +9,7 @@ namespace Tiny.RestClient { /// - /// Collection of + /// Collection of . /// public class Listeners : ICollection, IListener { From e5d17c6c39ff36b05d7e4649b95383fb52b26bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:04 +0200 Subject: [PATCH 40/55] fix comment --- .../MultipartFormContent/IMultipartFromDataExecutableRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataExecutableRequest.cs b/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataExecutableRequest.cs index af5da83..f72e4c1 100644 --- a/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataExecutableRequest.cs +++ b/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataExecutableRequest.cs @@ -3,7 +3,7 @@ namespace Tiny.RestClient { /// - /// Interface IMultiPartFromDataRequest + /// Interface IMultiPartFromDataRequest. /// /// /// From a17503cababe99a2f106db553650640a3cf861b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:12 +0200 Subject: [PATCH 41/55] fix comment --- .../IMultipartFromDataRequest.cs | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataRequest.cs b/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataRequest.cs index 0b6c153..3258080 100644 --- a/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataRequest.cs +++ b/Tiny.RestClient/Request/MultipartFormContent/IMultipartFromDataRequest.cs @@ -3,7 +3,7 @@ namespace Tiny.RestClient { /// - /// Interface IMultiPartFromDataRequest + /// Interface IMultiPartFromDataRequest. /// public interface IMultipartFromDataRequest { @@ -11,33 +11,33 @@ public interface IMultipartFromDataRequest /// Adds a byte array as content. /// /// The content. - /// The name of the item - /// The name of the file + /// The name of the item. + /// The name of the file. /// The content type of the file. - /// The current request - /// thrown when data is null + /// The current request. + /// thrown when data is null. IMultiPartFromDataExecutableRequest AddByteArray(byte[] data, string name = null, string fileName = null, string contentType = "application/octet-stream"); /// /// Adds the content. /// /// The content. - /// The name of the item - /// The name of the file - /// The content type of the file - /// The current request - /// thrown when data is null + /// The name of the item. + /// The name of the file. + /// The content type of the file. + /// The current request. + /// thrown when data is null. IMultiPartFromDataExecutableRequest AddString(string data, string name = null, string fileName = null, string contentType = "text/plain"); /// /// Adds the content. /// /// The content. - /// The name of the item - /// The name of the file - /// The content type of the file - /// The current request - /// thrown when data is null + /// The name of the item. + /// The name of the file. + /// The content type of the file. + /// The current request. + /// thrown when data is null. IMultiPartFromDataExecutableRequest AddStream(Stream data, string name = null, string fileName = null, string contentType = "application/octet-stream"); /// @@ -45,32 +45,32 @@ public interface IMultipartFromDataRequest /// /// The type of the t content. /// The content. - /// The name of the item - /// The name of the file - /// Override the default serializer setted on the client. If null use default serializer - /// Add compresion system use ton compress content - /// The current request - /// thrown when content is null + /// The name of the item. + /// The name of the file. + /// Override the default serializer setted on the client. If null use default serializer. + /// Add compresion system use ton compress content. + /// The current request. + /// thrown when content is null. IMultiPartFromDataExecutableRequest AddContent(TContent content, string name = null, string fileName = null, IFormatter serializer = null, ICompression compression = null); #if !FILEINFO_NOT_SUPPORTED /// /// Adds the content. /// /// The content. - /// The name of the item - /// The name of the file - /// The content type of the file - /// The current request - /// thrown when content is null + /// The name of the item. + /// The name of the file. + /// The content type of the file. + /// The current request. + /// thrown when content is null. IMultiPartFromDataExecutableRequest AddFileContent(FileInfo content, string name, string fileName, string contentType); /// /// Adds the content. /// /// The content. - /// The content type of the file - /// The current request - /// thrown when content is null + /// The content type of the file. + /// The current request. + /// thrown when content is null. IMultiPartFromDataExecutableRequest AddFileContent(FileInfo content, string contentType); #endif } From 2eae907c101829c4f00524941a6d2e305db70e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:18 +0200 Subject: [PATCH 42/55] fix comment --- Tiny.RestClient/Request/IExecutableRequest.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Tiny.RestClient/Request/IExecutableRequest.cs b/Tiny.RestClient/Request/IExecutableRequest.cs index 2d1aec9..edfdf91 100644 --- a/Tiny.RestClient/Request/IExecutableRequest.cs +++ b/Tiny.RestClient/Request/IExecutableRequest.cs @@ -6,7 +6,7 @@ namespace Tiny.RestClient { /// - /// Interface IExecutableRequest + /// Interface IExecutableRequest. /// public interface IExecutableRequest { @@ -15,7 +15,7 @@ public interface IExecutableRequest /// /// The type of the TResult. /// The cancellation token. - /// + /// . Task ExecuteAsync(CancellationToken cancellationToken = default); /// @@ -24,43 +24,43 @@ public interface IExecutableRequest /// The type of the TResult. /// Allow to override the formatter use for the deserialization. /// The cancellation token. - /// Task of TResukt + /// Task of TResukt. Task ExecuteAsync(IFormatter formatter, CancellationToken cancellationToken = default); /// /// Executes the request. /// /// The cancellation token. - /// + /// . Task ExecuteAsStreamAsync(CancellationToken cancellationToken = default); /// /// Executes the request. /// /// The cancellation token. - /// Task of string + /// Task of string. Task ExecuteAsStringAsync(CancellationToken cancellationToken = default); /// /// Executes the request. /// /// The cancellation token. - /// Task of byte array + /// Task of byte array. Task ExecuteAsByteArrayAsync(CancellationToken cancellationToken = default); /// /// Executes the request. /// /// The cancellation token. - /// Task of + /// Task of . Task ExecuteAsHttpResponseMessageAsync(CancellationToken cancellationToken = default); #if !FILEINFO_NOT_SUPPORTED /// - /// Download file async + /// Download file async. /// - /// path to download + /// path to download. /// The cancellation token. - /// return a file info + /// return a file info. Task DownloadFileAsync(string path, CancellationToken cancellationToken = default); #endif @@ -68,7 +68,7 @@ public interface IExecutableRequest /// Executes the request. /// /// The cancellation token. - /// A task + /// A task. Task ExecuteAsync(CancellationToken cancellationToken = default); } } \ No newline at end of file From ea89c797dc89db741cb467f554ca7176b83dd4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:25 +0200 Subject: [PATCH 43/55] fix comment --- Tiny.RestClient/Request/IFormRequest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tiny.RestClient/Request/IFormRequest.cs b/Tiny.RestClient/Request/IFormRequest.cs index c9a2985..7c90617 100644 --- a/Tiny.RestClient/Request/IFormRequest.cs +++ b/Tiny.RestClient/Request/IFormRequest.cs @@ -3,7 +3,7 @@ namespace Tiny.RestClient { /// - /// Interface IFormRequest + /// Interface IFormRequest. /// /// public interface IFormRequest : IParameterRequest @@ -13,14 +13,14 @@ public interface IFormRequest : IParameterRequest /// /// The key. /// The value. - /// The current request + /// The current request. IFormRequest AddFormParameter(string key, string value); /// /// Adds the form parameters. /// /// The datas. - /// The current request + /// The current request. IFormRequest AddFormParameters(IEnumerable> datas); } } \ No newline at end of file From 29b6e9f40f24b396c2ff5f1bed203fa7fc4e1e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:37 +0200 Subject: [PATCH 44/55] fix comment --- Tiny.RestClient/Request/IParameterRequest.cs | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Tiny.RestClient/Request/IParameterRequest.cs b/Tiny.RestClient/Request/IParameterRequest.cs index 86b0a6c..0d5bd45 100644 --- a/Tiny.RestClient/Request/IParameterRequest.cs +++ b/Tiny.RestClient/Request/IParameterRequest.cs @@ -1,16 +1,16 @@ namespace Tiny.RestClient { /// - /// Interface IParameterRequest + /// Interface IParameterRequest. /// /// public interface IParameterRequest : IExecutableRequest { /// - /// Fill header of response + /// Fill header of response. /// - /// Header filled after execute method - /// The current request + /// Header filled after execute method. + /// The current request. IParameterRequest FillResponseHeaders(out Headers headers); /// @@ -18,7 +18,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddHeader(string key, string value); /// @@ -26,7 +26,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, string value); /// @@ -34,7 +34,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, bool value); /// @@ -42,7 +42,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, bool? value); /// @@ -50,7 +50,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, int value); /// @@ -58,7 +58,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, int? value); /// @@ -66,7 +66,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, uint value); /// @@ -74,7 +74,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, uint? value); /// @@ -82,7 +82,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, double value); /// @@ -90,7 +90,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, double? value); /// @@ -98,7 +98,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, decimal value); /// @@ -106,7 +106,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, decimal? value); /// @@ -114,7 +114,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, float value); /// @@ -122,7 +122,7 @@ public interface IParameterRequest : IExecutableRequest /// /// The key. /// The value. - /// The current request + /// The current request. IParameterRequest AddQueryParameter(string key, float? value); } } From da904d2c95fe65e4ba264b9f75e483eb4481ea24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:43 +0200 Subject: [PATCH 45/55] fix comment --- Tiny.RestClient/Request/IRequest.cs | 58 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Tiny.RestClient/Request/IRequest.cs b/Tiny.RestClient/Request/IRequest.cs index 112c324..44dd5fe 100644 --- a/Tiny.RestClient/Request/IRequest.cs +++ b/Tiny.RestClient/Request/IRequest.cs @@ -4,38 +4,38 @@ namespace Tiny.RestClient { /// - /// Interface IRequest + /// Interface IRequest. /// /// /// public interface IRequest : IExecutableRequest, IFormRequest { /// - /// Add a basic authentication credentials + /// Add a basic authentication credentials. /// - /// the username - /// the password - /// The current request + /// the username. + /// the password. + /// The current request. IRequest WithBasicAuthentication(string username, string password); /// - /// Add a bearer token in the request headers + /// Add a bearer token in the request headers. /// - /// token value - /// The current request + /// token value. + /// The current request. IRequest WithOAuthBearer(string token); /// - /// With timeout for current request + /// With timeout for current request. /// - /// timeout - /// The current request + /// timeout. + /// The current request. IRequest WithTimeout(TimeSpan timeout); /// - /// With a specific etag container + /// With a specific etag container. /// - /// the eTag container + /// the eTag container. /// IRequest WithETagContainer(IETagContainer eTagContainer); @@ -45,48 +45,48 @@ public interface IRequest : IExecutableRequest, IFormRequest /// The type of the t content. /// The content. /// Override the default serializer setted on the client. - /// Add a compression system to compress your content - /// The current request + /// Add a compression system to compress your content. + /// The current request. IParameterRequest AddContent(TContent content, IFormatter serializer = null, ICompression compression = null); /// - /// Add byte array as content of request + /// Add byte array as content of request. /// /// The byte array. - /// The Content type - /// The current request + /// The Content type. + /// The current request. IParameterRequest AddByteArrayContent(byte[] byteArray, string contentType = "application/octet-stream"); /// - /// Adds stream as content + /// Adds stream as content. /// /// The stream. - /// The content type - /// The current request + /// The content type. + /// The current request. IParameterRequest AddStreamContent(Stream stream, string contentType = "application/octet-stream"); /// - /// Adds string as content (without apply any serialization) + /// Adds string as content (without apply any serialization). /// /// The content. - /// The content type - /// The current request + /// The content type. + /// The current request. IParameterRequest AddStringContent(string content, string contentType = "text/plain"); #if !FILEINFO_NOT_SUPPORTED /// /// Adds file as content. /// /// The file to add as content of request. - /// The content type - /// The current request + /// The content type. + /// The current request. IParameterRequest AddFileContent(FileInfo file, string contentType); #endif /// - /// As a multipart data from request + /// As a multipart data from request. /// - /// content type of the request (default value = "multipart/form-data") - /// The current request + /// content type of the request (default value = "multipart/form-data"). + /// The current request. IMultipartFromDataRequest AsMultiPartFromDataRequest(string contentType = "multipart/form-data"); } } \ No newline at end of file From 8d74c64b75f8a77d513a6edc126daa14769645fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 20:20:50 +0200 Subject: [PATCH 46/55] fix comment --- Tiny.RestClient/RestClientSettings.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Tiny.RestClient/RestClientSettings.cs b/Tiny.RestClient/RestClientSettings.cs index c64ca2c..c7ab3ee 100644 --- a/Tiny.RestClient/RestClientSettings.cs +++ b/Tiny.RestClient/RestClientSettings.cs @@ -4,7 +4,7 @@ namespace Tiny.RestClient { /// - /// All settings of + /// All settings of . /// public class RestClientSettings { @@ -25,22 +25,22 @@ internal RestClientSettings() } /// - /// Add to all request the AcceptLanguage based on CurrentCulture of the Thread + /// Add to all request the AcceptLanguage based on CurrentCulture of the Thread. /// public bool AddAcceptLanguageBasedOnCurrentCulture { get; set; } /// - /// Get or set the ETagContainer + /// Get or set the ETagContainer. /// public IETagContainer ETagContainer { get; set; } /// - /// Get or set the default timeout of each request + /// Get or set the default timeout of each request. /// public TimeSpan DefaultTimeout { get; set; } /// - /// Gets or set the encoding use by the client + /// Gets or set the encoding use by the client. /// public Encoding Encoding { @@ -71,12 +71,12 @@ public Headers DefaultHeaders public Listeners Listeners { get; private set; } /// - /// Gets the list of formatter used to serialize and deserialize data + /// Gets the list of formatter used to serialize and deserialize data. /// public Formatters Formatters { get; private set; } /// - /// Compression / decompression system enabled + /// Compression / decompression system enabled. /// public Compressions Compressions { get; private set; } } From 4ab6e021a79d9f5f1494459dca55cac0476ad87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:14:35 +0200 Subject: [PATCH 47/55] Encapsulate exception if needed --- Tiny.RestClient/RestClientSettings.cs | 5 +++++ Tiny.RestClient/TinyRestClient.cs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Tiny.RestClient/RestClientSettings.cs b/Tiny.RestClient/RestClientSettings.cs index c7ab3ee..61142c9 100644 --- a/Tiny.RestClient/RestClientSettings.cs +++ b/Tiny.RestClient/RestClientSettings.cs @@ -79,5 +79,10 @@ public Headers DefaultHeaders /// Compression / decompression system enabled. /// public Compressions Compressions { get; private set; } + + /// + /// Handler used when HttpException will be throw (can be used to transform exception). + /// + public Func EncapsulateHttpExceptionHandler { get; private set; } } } \ No newline at end of file diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index 5705cc2..8f480cd 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -819,6 +819,12 @@ private async Task HandleResponseAsync( response.Headers, ex); + var handler = Settings.EncapsulateHttpExceptionHandler; + if (handler != null) + { + throw handler(newEx); + } + throw newEx; } } From 4585c486c8a8b69c87812a2c4c26494cf95a647d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:20:24 +0200 Subject: [PATCH 48/55] Add test --- .../HttpExceptionTests.cs | 23 +++++++++++++++++++ Tiny.RestClient/RestClientSettings.cs | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index 986c2cd..2470292 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -28,5 +28,28 @@ public async Task CheckIfHttpExceptionReadHeaders() Assert.IsTrue(exceptionThrowed, $"An {nameof(HttpException)} must be throwed"); } + + [ExpectedException(typeof(NotFoundCustomException))] + [TestMethod] + public async Task CheckIfEnclapsulationWorks() + { + var client = GetNewClient(); + client.Settings.EncapsulateHttpExceptionHandler = (ex) => + { + if (ex.StatusCode == System.Net.HttpStatusCode.NotFound) + { + return new NotFoundCustomException(); + } + + return ex; + }; + + // Call an api not found (the ETag header is present in all responses on this server) + await client.GetRequest("APIWhichNotExists").ExecuteAsync(); + } + + internal class NotFoundCustomException : Exception + { + } } } diff --git a/Tiny.RestClient/RestClientSettings.cs b/Tiny.RestClient/RestClientSettings.cs index 61142c9..d7b53db 100644 --- a/Tiny.RestClient/RestClientSettings.cs +++ b/Tiny.RestClient/RestClientSettings.cs @@ -81,8 +81,8 @@ public Headers DefaultHeaders public Compressions Compressions { get; private set; } /// - /// Handler used when HttpException will be throw (can be used to transform exception). + /// Gets or set the handler used when HttpException will be throw (can be used to transform exception). /// - public Func EncapsulateHttpExceptionHandler { get; private set; } + public Func EncapsulateHttpExceptionHandler { get; set; } } } \ No newline at end of file From a9782161ab44421886dc230b13974c22ab3f1239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:33:46 +0200 Subject: [PATCH 49/55] fix comment --- Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index 2470292..877a794 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -44,7 +44,7 @@ public async Task CheckIfEnclapsulationWorks() return ex; }; - // Call an api not found (the ETag header is present in all responses on this server) + // Call an API wich throw NotFound error await client.GetRequest("APIWhichNotExists").ExecuteAsync(); } From b682714b11cec52a8b234c726794a21a77daf1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:34:18 +0200 Subject: [PATCH 50/55] Update README.md --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index e22f88b..4fb7af9 100644 --- a/README.md +++ b/README.md @@ -340,6 +340,28 @@ catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.Intern throw new ServerErrorException($"{ex.Message} {ex.ReasonPhrase}"); } ``` + +### Enclapsulate HttpExceptions +We can setup a global handler to provide a logic to encapsulate HttpException automatically. + +For example I can choose to translate all HttpException with StatusCode NotFound in a NotFoundCustomException. +```cs +client.Settings.EncapsulateHttpExceptionHandler = (ex) => +{ + if (ex.StatusCode == System.Net.HttpStatusCode.NotFound) + { + return new NotFoundCustomException(); + } + + return ex; +}; +``` + +Now if I call an API wich respond with status code NotFound it will throw automaticaly my custom exception. +```cs +// Call an API wich throw NotFound error +await client.GetRequest("APIWhichNotExists").ExecuteAsync(); +``` ## ETag The lib supports the Entity tag but it's not enabled by default. From a73ce3b49a8c9dab881356777d88bb0f0f326ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:36:36 +0200 Subject: [PATCH 51/55] Update RELEASE-NOTES.md --- RELEASE-NOTES.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 96e7c63..2c03564 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -2,6 +2,27 @@ ## 1.6.2 * Now HttpException expose the headers of the response * Constructor of HttpException is now internal +* Add possibility to encapsulate HttpException automatically. + +We can setup a global handler to provide a logic to encapsulate HttpException automatically. +For example I can choose to translate all HttpException with StatusCode NotFound in a NotFoundCustomException. +```cs +client.Settings.EncapsulateHttpExceptionHandler = (ex) => +{ + if (ex.StatusCode == System.Net.HttpStatusCode.NotFound) + { + return new NotFoundCustomException(); + } + + return ex; +}; +``` + +Now if I call an API wich respond with status code NotFound it will throw automaticaly my custom exception. +```cs +// Call an API wich throw NotFound error +await client.GetRequest("APIWhichNotExists").ExecuteAsync(); +``` ## 1.6.1 * Fix patch request which sent patch verb in lowercase From bd448ea82340939b42b5d94a9de8b1147b7b36f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 21:48:39 +0200 Subject: [PATCH 52/55] remove using --- Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs index 877a794..e8d3b4e 100644 --- a/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs +++ b/Tests/Tiny.RestClient.Tests/HttpExceptionTests.cs @@ -1,7 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace Tiny.RestClient.Tests From b43bd89294aab63b2edfc7eef7201a46b71fc471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Sat, 4 May 2019 22:00:36 +0200 Subject: [PATCH 53/55] Update Tiny.RestClient.csproj --- Tiny.RestClient/Tiny.RestClient.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiny.RestClient/Tiny.RestClient.csproj b/Tiny.RestClient/Tiny.RestClient.csproj index 20509fe..3ea40b5 100644 --- a/Tiny.RestClient/Tiny.RestClient.csproj +++ b/Tiny.RestClient/Tiny.RestClient.csproj @@ -2,7 +2,7 @@ netstandard1.1;netstandard1.2;netstandard1.3;netstandard2.0;net45;net46;net47 1.6.2 - Copyright © Jérôme Giacomini 2018 + Copyright © Jérôme Giacomini 2019 en Tiny.RestClient Jérôme Giacomini From a166f912684b86dc9b749092b9598293badb608e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Tue, 21 May 2019 06:53:27 +0200 Subject: [PATCH 54/55] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 4fb7af9..66d7318 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,23 @@ client.GetRequest("City/All"). ExecuteAsync(); ``` + +#### Calculate headers before send the requests + +Before send requests to server we can add calculate dynamically the headers to add to resquest like below : +```cs +client.Settings.CalculateHeadersHandler = async () => +{ + var token = await GetACustomTokenAsync(); + + var headers = new Headers + { + { "CustomToken", token }, + }; + return headers; +}; + ``` + #### Read headers of response ```cs @@ -108,6 +125,7 @@ foreach(var header in headersOfResponse) } ``` + ### Basic GET http requests ```cs From 8e9276aefcc67bba276b8aad2add02204fd06da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20GIACOMINI?= Date: Tue, 21 May 2019 07:02:04 +0200 Subject: [PATCH 55/55] Calculate headers before send request (#90) Add possibility to calculate headers just before send requests --- RELEASE-NOTES.md | 17 ++++++++ .../Controllers/HeadersTestController.cs | 24 +++++++++++ Tests/Tiny.RestClient.Tests/HeaderTests.cs | 43 +++++++++++++++++++ Tiny.RestClient/Request/Headers/Headers.cs | 5 ++- Tiny.RestClient/RestClientSettings.cs | 6 +++ Tiny.RestClient/Tiny.RestClient.csproj | 4 +- Tiny.RestClient/TinyRestClient.cs | 15 +++++++ 7 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 Tests/Tiny.RestClient.ForTest.Api/Controllers/HeadersTestController.cs create mode 100644 Tests/Tiny.RestClient.Tests/HeaderTests.cs diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 2c03564..d4e2c67 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,4 +1,21 @@ # Release notes +# 1.6.3 +* Now calculate dynamically the headers to add to resquest. + +In this sample we get a custom token and add it to all our requests => +```cs +client.Settings.CalculateHeadersHandler = async () => +{ + var token = await GetACustomTokenAsync(); + + var headers = new Headers + { + { "CustomToken", token }, + }; + return headers; +}; + ``` + ## 1.6.2 * Now HttpException expose the headers of the response * Constructor of HttpException is now internal diff --git a/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeadersTestController.cs b/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeadersTestController.cs new file mode 100644 index 0000000..1c49e20 --- /dev/null +++ b/Tests/Tiny.RestClient.ForTest.Api/Controllers/HeadersTestController.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Tiny.RestClient.ForTest.Api.Controllers +{ + [Route("api/HeadersTest")] + [ApiController] + public class HeadersTestController : ControllerBase + { + [HttpGet("NoResponse")] + public Task NoResponse() + { + foreach (var header in Request.Headers) + { + Response.Headers.Add("FROM_CLIENT" + header.Key, header.Value); + } + + return Task.Delay(1); + } + } +} \ No newline at end of file diff --git a/Tests/Tiny.RestClient.Tests/HeaderTests.cs b/Tests/Tiny.RestClient.Tests/HeaderTests.cs new file mode 100644 index 0000000..bfe4be3 --- /dev/null +++ b/Tests/Tiny.RestClient.Tests/HeaderTests.cs @@ -0,0 +1,43 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tiny.RestClient.Tests +{ + [TestClass] + public class HeaderTests : BaseTest + { + [TestMethod] + public async Task CalculateHeadersTest() + { + var client = GetNewClient(); + + var headers = new Headers + { + { "Header1", "Value1" }, + { "Header2", "Value2" }, + { "Header3", "Value3" } + }; + + client.Settings.CalculateHeadersHandler = () => + { + return Task.FromResult(headers); + }; + + await client. + GetRequest("HeadersTest/NoResponse"). + FillResponseHeaders(out Headers responseHeaders). + ExecuteAsync(); + + foreach (var sendedHeader in headers) + { + Assert.IsTrue(responseHeaders.Any(h => h.Key == "FROM_CLIENT" + sendedHeader.Key), $"{sendedHeader.Key} seem not passed to server side"); + var responseHeader = responseHeaders.FirstOrDefault(h => h.Key == "FROM_CLIENT" + sendedHeader.Key); + Assert.IsTrue(sendedHeader.Value.First() == responseHeader.Value.First(), $"Values for header {sendedHeader.Key} seem not match with values resend by server"); + } + } + } +} diff --git a/Tiny.RestClient/Request/Headers/Headers.cs b/Tiny.RestClient/Request/Headers/Headers.cs index 326fc82..36c2a1f 100644 --- a/Tiny.RestClient/Request/Headers/Headers.cs +++ b/Tiny.RestClient/Request/Headers/Headers.cs @@ -13,7 +13,10 @@ public class Headers : IEnumerable>> { private Dictionary> _headers; - internal Headers() + /// + /// Initializes a new instance of the class. + /// + public Headers() { _headers = new Dictionary>(); } diff --git a/Tiny.RestClient/RestClientSettings.cs b/Tiny.RestClient/RestClientSettings.cs index d7b53db..0e78a36 100644 --- a/Tiny.RestClient/RestClientSettings.cs +++ b/Tiny.RestClient/RestClientSettings.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using System.Threading.Tasks; namespace Tiny.RestClient { @@ -65,6 +66,11 @@ public Headers DefaultHeaders get; private set; } + /// + /// Gets or set the handler used to calculate headers before send request. + /// + public Func> CalculateHeadersHandler { get; set; } + /// /// Log all requests. /// diff --git a/Tiny.RestClient/Tiny.RestClient.csproj b/Tiny.RestClient/Tiny.RestClient.csproj index 3ea40b5..d2092ae 100644 --- a/Tiny.RestClient/Tiny.RestClient.csproj +++ b/Tiny.RestClient/Tiny.RestClient.csproj @@ -1,7 +1,7 @@  netstandard1.1;netstandard1.2;netstandard1.3;netstandard2.0;net45;net46;net47 - 1.6.2 + 1.6.3 Copyright © Jérôme Giacomini 2019 en Tiny.RestClient @@ -36,7 +36,7 @@ https://github.com/jgiacomini/Tiny.RestClient.git git 3.0.3 - See release notes at https://github.com/jgiacomini/Tiny.RestClient/blob/1.6.2/RELEASE-NOTES.md + See release notes at https://github.com/jgiacomini/Tiny.RestClient/blob/1.6.3/RELEASE-NOTES.md true true $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/Tiny.RestClient/TinyRestClient.cs b/Tiny.RestClient/TinyRestClient.cs index 8f480cd..e72d7c1 100644 --- a/Tiny.RestClient/TinyRestClient.cs +++ b/Tiny.RestClient/TinyRestClient.cs @@ -590,6 +590,13 @@ private async Task SendRequestAsync( stopwatch = new Stopwatch(); } + Headers calculatedHeaders = null; + var calculateHeadersHandler = Settings.CalculateHeadersHandler; + if (calculateHeadersHandler != null) + { + calculatedHeaders = await calculateHeadersHandler.Invoke(); + } + using (var request = new HttpRequestMessage(httpMethod, uri)) { if (deserializer == null) @@ -625,6 +632,14 @@ private async Task SendRequestAsync( } } + if (calculatedHeaders != null) + { + foreach (var item in calculatedHeaders) + { + request.Headers.Add(item.Key, item.Value); + } + } + if (eTagContainer != null) { if (!request.Headers.IfNoneMatch.Any())