@@ -48,8 +48,6 @@ public async Task<T> GetAsync<T>(
4848 JsonSerializerSettings serializerSettings = null ,
4949 CancellationToken cancellationToken = default )
5050 {
51- EnsureHttpClient ( ) ;
52-
5351 var response = await SendAsync ( uri , HttpMethod . Get , queryParams , headers , cancellationToken : cancellationToken ) ;
5452
5553 return await response . ParseStreamAsync < T > ( serializerSettings ) ;
@@ -82,6 +80,8 @@ private async Task<HttpResponseMessage> SendAsync(
8280 Action < HttpRequestMessage > attachContent = null ,
8381 CancellationToken cancellationToken = default )
8482 {
83+ EnsureHttpClient ( ) ;
84+
8585 requestUri = AddQueryString ( requestUri , queryParams ) ;
8686
8787 HttpRequestMessage httpRequest = new HttpRequestMessage ( httpMethod , requestUri ) ;
@@ -121,8 +121,6 @@ public async Task<T> PostAsync<T>(
121121 JsonSerializerSettings serializerSettings = null ,
122122 CancellationToken cancellationToken = default )
123123 {
124- EnsureHttpClient ( ) ;
125-
126124 void AttachContent ( HttpRequestMessage httpRequest )
127125 {
128126 httpRequest . Content = new StringContent ( JsonConvert . SerializeObject ( body , defaultSerializerSettings ) , Encoding . UTF8 , "application/json" ) ;
@@ -135,8 +133,6 @@ void AttachContent(HttpRequestMessage httpRequest)
135133
136134 public async Task < T > PatchAsync < T > ( string uri , object body , IDictionary < string , string > queryParams = null , IDictionary < string , string > headers = null , JsonSerializerSettings serializerSettings = null , CancellationToken cancellationToken = default )
137135 {
138- EnsureHttpClient ( ) ;
139-
140136 void AttachContent ( HttpRequestMessage httpRequest )
141137 {
142138 var serializedBody = JsonConvert . SerializeObject ( body , defaultSerializerSettings ) ;
0 commit comments