From 5488b5fb1bdefd9620f7120a9b4fd6917fc14a19 Mon Sep 17 00:00:00 2001 From: Niels Timmermans Date: Wed, 23 Nov 2016 10:25:41 +0100 Subject: [PATCH 1/2] Cache default httpclient --- CSharpHTTPClient/Client.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CSharpHTTPClient/Client.cs b/CSharpHTTPClient/Client.cs index f54da8a..0b21086 100644 --- a/CSharpHTTPClient/Client.cs +++ b/CSharpHTTPClient/Client.cs @@ -14,6 +14,7 @@ namespace SendGrid.CSharp.HTTP.Client { public class Response { + private static HttpClient _httpClient = new HttpClient(); public HttpStatusCode StatusCode; public HttpContent Body; public HttpResponseHeaders Headers; @@ -194,7 +195,7 @@ private HttpClient BuildHttpClient() return new HttpClient(httpClientHandler); } - return new HttpClient(); + return _httpClient; } /// From 1bbd9e8985849c60be6144b3f0be18ded67bcbb3 Mon Sep 17 00:00:00 2001 From: Niels Timmermans Date: Tue, 29 Nov 2016 09:36:12 +0100 Subject: [PATCH 2/2] Move httpclient --- CSharpHTTPClient/Client.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CSharpHTTPClient/Client.cs b/CSharpHTTPClient/Client.cs index 0b21086..39a01a7 100644 --- a/CSharpHTTPClient/Client.cs +++ b/CSharpHTTPClient/Client.cs @@ -13,8 +13,7 @@ namespace SendGrid.CSharp.HTTP.Client { public class Response - { - private static HttpClient _httpClient = new HttpClient(); + { public HttpStatusCode StatusCode; public HttpContent Body; public HttpResponseHeaders Headers; @@ -64,6 +63,7 @@ public virtual Dictionary DeserializeResponseHeaders(HttpRespons public class Client : DynamicObject { + private static HttpClient _httpClient = new HttpClient(); public string Host; public Dictionary RequestHeaders; public string Version;