-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpClientWithCache.cs
More file actions
532 lines (427 loc) · 23.8 KB
/
HttpClientWithCache.cs
File metadata and controls
532 lines (427 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
using System.Net.Http.Json;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Reliable.HttpClient.Caching.Abstractions;
namespace Reliable.HttpClient.Caching;
/// <summary>
/// Universal HTTP client with caching implementation that can handle multiple response types.
/// This is the recommended approach when you need caching across different response types in a single client.
/// For type-safe caching of specific response types, consider using CachedHttpClient<T> from Reliable.HttpClient.Caching.Generic namespace.
/// </summary>
/// <param name="httpClient">HTTP client instance</param>
/// <param name="cache">Memory cache instance</param>
/// <param name="responseHandler">Universal response handler</param>
/// <param name="cacheOptions">Cache options including default headers and other settings</param>
/// <param name="cacheKeyGenerator">Cache key generator (optional)</param>
/// <param name="logger">Logger instance (optional)</param>
public class HttpClientWithCache(
System.Net.Http.HttpClient httpClient,
IMemoryCache cache,
IHttpResponseHandler responseHandler,
HttpCacheOptions? cacheOptions = null,
ISimpleCacheKeyGenerator? cacheKeyGenerator = null,
ILogger<HttpClientWithCache>? logger = null) : IHttpClientWithCache, IHttpClientAdapter
{
private readonly System.Net.Http.HttpClient _httpClient = httpClient;
private readonly IMemoryCache _cache = cache;
private readonly IHttpResponseHandler _responseHandler = responseHandler;
private readonly HttpCacheOptions _cacheOptions = cacheOptions ?? new HttpCacheOptions();
private readonly ISimpleCacheKeyGenerator _cacheKeyGenerator = cacheKeyGenerator ?? new DefaultSimpleCacheKeyGenerator();
private readonly ILogger<HttpClientWithCache>? _logger = logger;
/// <inheritdoc />
public async Task<TResponse> GetAsync<TResponse>(
string requestUri,
TimeSpan? cacheDuration = null,
CancellationToken cancellationToken = default) where TResponse : class
{
var cacheKey = GenerateCacheKey<TResponse>(requestUri, _cacheOptions.DefaultHeaders);
if (_cache.TryGetValue(cacheKey, out TResponse? cachedResult) && cachedResult is not null)
{
_logger?.LogDebug("Cache hit for key: {CacheKey}", cacheKey);
return cachedResult;
}
_logger?.LogDebug("Cache miss for key: {CacheKey}", cacheKey);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Get, requestUri, _cacheOptions.DefaultHeaders);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
TimeSpan duration = cacheDuration ?? _cacheOptions.DefaultExpiry;
_cache.Set(cacheKey, result, duration);
_logger?.LogDebug("Cached result for key: {CacheKey}, Duration: {Duration}", cacheKey, duration);
return result;
}
/// <inheritdoc />
public async Task<TResponse> GetAsync<TResponse>(
Uri requestUri,
TimeSpan? cacheDuration = null,
CancellationToken cancellationToken = default) where TResponse : class
{
return await GetAsync<TResponse>(requestUri.ToString(), cacheDuration, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<TResponse> GetAsync<TResponse>(
string requestUri,
IDictionary<string, string> headers,
TimeSpan? cacheDuration = null,
CancellationToken cancellationToken = default) where TResponse : class
{
var cacheKey = GenerateCacheKey<TResponse>(requestUri, headers);
if (_cache.TryGetValue(cacheKey, out TResponse? cachedResult) && cachedResult is not null)
{
_logger?.LogDebug("Cache hit for key: {CacheKey}", cacheKey);
return cachedResult;
}
_logger?.LogDebug("Cache miss for key: {CacheKey}", cacheKey);
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Get, requestUri, allHeaders);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
TimeSpan duration = cacheDuration ?? _cacheOptions.DefaultExpiry;
_cache.Set(cacheKey, result, duration);
_logger?.LogDebug("Cached result for key: {CacheKey}, Duration: {Duration}", cacheKey, duration);
return result;
}
/// <inheritdoc />
public async Task<TResponse> GetAsync<TResponse>(
Uri requestUri,
IDictionary<string, string> headers,
TimeSpan? cacheDuration = null,
CancellationToken cancellationToken = default) where TResponse : class
{
return await GetAsync<TResponse>(requestUri.ToString(), headers, cacheDuration, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<TResponse> PostAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
CancellationToken cancellationToken = default) where TResponse : class
{
HttpResponseMessage response = await _httpClient.PostAsJsonAsync(requestUri, content, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> PostAsync<TRequest, TResponse>(
Uri requestUri,
TRequest content,
CancellationToken cancellationToken = default) where TResponse : class
{
return await PostAsync<TRequest, TResponse>(requestUri.ToString(), content, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<TResponse> PostAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Post, requestUri, allHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> PostAsync<TRequest, TResponse>(
Uri requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
return await PostAsync<TRequest, TResponse>(requestUri.ToString(), content, headers, cancellationToken).ConfigureAwait(false);
}
public async Task<HttpResponseMessage> PostAsync<TRequest>(
string requestUri,
TRequest content,
CancellationToken cancellationToken = default)
{
HttpResponseMessage response = await _httpClient.PostAsJsonAsync(requestUri, content, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
public async Task<HttpResponseMessage> PostAsync<TRequest>(
string requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default)
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Post, requestUri, allHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
/// <inheritdoc />
public async Task<TResponse> PatchAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
CancellationToken cancellationToken = default) where TResponse : class
{
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Patch, requestUri, _cacheOptions.DefaultHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> PatchAsync<TRequest, TResponse>(
Uri requestUri,
TRequest content,
CancellationToken cancellationToken = default) where TResponse : class
{
return await PatchAsync<TRequest, TResponse>(requestUri.ToString(), content, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<TResponse> PatchAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Patch, requestUri, allHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> PatchAsync<TRequest, TResponse>(
Uri requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
return await PatchAsync<TRequest, TResponse>(requestUri.ToString(), content, headers, cancellationToken).ConfigureAwait(false);
}
/// <inheritdoc />
public async Task<HttpResponseMessage> PatchAsync<TRequest>(
string requestUri,
TRequest content,
CancellationToken cancellationToken = default)
{
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Patch, requestUri, _cacheOptions.DefaultHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
/// <inheritdoc />
public async Task<HttpResponseMessage> PatchAsync<TRequest>(
string requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default)
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Patch, requestUri, allHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
/// <inheritdoc />
public async Task<TResponse> PutAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
CancellationToken cancellationToken = default) where TResponse : class
{
HttpResponseMessage response = await _httpClient.PutAsJsonAsync(requestUri, content, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> PutAsync<TRequest, TResponse>(
string requestUri,
TRequest content,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Put, requestUri, allHeaders);
request.Content = JsonContent.Create(content);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> DeleteAsync<TResponse>(
string requestUri,
CancellationToken cancellationToken = default) where TResponse : class
{
HttpResponseMessage response = await _httpClient.DeleteAsync(requestUri, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
/// <inheritdoc />
public async Task<TResponse> DeleteAsync<TResponse>(
string requestUri,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default) where TResponse : class
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Delete, requestUri, allHeaders);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
TResponse result = await _responseHandler.HandleAsync<TResponse>(response, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful response handling
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return result;
}
public async Task<HttpResponseMessage> DeleteAsync(
string requestUri,
CancellationToken cancellationToken = default)
{
HttpResponseMessage response = await _httpClient.DeleteAsync(requestUri, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
public async Task<HttpResponseMessage> DeleteAsync(
string requestUri,
IDictionary<string, string> headers,
CancellationToken cancellationToken = default)
{
Dictionary<string, string> allHeaders = MergeHeaders(_cacheOptions.DefaultHeaders, headers);
using HttpRequestMessage request = CreateRequestWithHeaders(HttpMethod.Delete, requestUri, allHeaders);
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
// Invalidate cache only after successful HTTP request (before response handler to maintain adapter contract)
await InvalidateRelatedCacheAsync(requestUri).ConfigureAwait(false);
return response;
}
/// <inheritdoc />
public Task InvalidateCacheAsync(string pattern)
{
// For now, we'll implement a simple approach
// In production, you might want to use a more sophisticated cache that supports pattern-based invalidation
_logger?.LogDebug("Cache invalidation requested for pattern: {Pattern}", pattern);
// Note: MemoryCache doesn't natively support pattern-based invalidation
// This is a limitation we acknowledge in the documentation
return Task.CompletedTask;
}
/// <inheritdoc />
public Task ClearCacheAsync()
{
// For MemoryCache, we can't easily clear all entries without disposing
// This is a known limitation documented in the API
_logger?.LogDebug("Cache clear requested");
return Task.CompletedTask;
}
private async Task InvalidateRelatedCacheAsync(string requestUri)
{
// Extract the base path to invalidate related GET requests
var uri = new Uri(requestUri, UriKind.RelativeOrAbsolute);
var basePath = uri.IsAbsoluteUri ? uri.AbsolutePath : requestUri;
// Remove any ID or query parameters for broader invalidation
var pathSegments = basePath.Split('/', StringSplitOptions.RemoveEmptyEntries);
if (pathSegments.Length > 0)
{
var resourcePath = string.Join('/', pathSegments[..^1]);
await InvalidateCacheAsync(resourcePath).ConfigureAwait(false);
}
}
private static HttpRequestMessage CreateRequestWithHeaders(
HttpMethod method, string requestUri, IDictionary<string, string>? headers = null)
{
var request = new HttpRequestMessage(method, requestUri);
if (headers is not null)
{
foreach (KeyValuePair<string, string> header in headers)
{
request.Headers.TryAddWithoutValidation(header.Key, header.Value);
}
}
return request;
}
private string GenerateCacheKey<TResponse>(string requestUri, IDictionary<string, string>? headers = null)
{
var allHeaders = new Dictionary<string, string>(_cacheOptions.DefaultHeaders, StringComparer.OrdinalIgnoreCase);
if (headers is not null)
{
foreach (KeyValuePair<string, string> header in headers)
{
allHeaders[header.Key] = header.Value; // Override default headers if same key
}
}
if (allHeaders.Count == 0)
{
return _cacheKeyGenerator.GenerateKey(typeof(TResponse).Name, requestUri);
}
var headerString = string.Join(';',
allHeaders.OrderBy(h => h.Key, StringComparer.OrdinalIgnoreCase)
.Select(h => $"{h.Key}={h.Value}"));
return _cacheKeyGenerator.GenerateKey(typeof(TResponse).Name, $"{requestUri}#{headerString}");
}
private static Dictionary<string, string> MergeHeaders(
IDictionary<string, string> defaultHeaders, IDictionary<string, string>? customHeaders = null)
{
var result = new Dictionary<string, string>(defaultHeaders, StringComparer.OrdinalIgnoreCase);
if (customHeaders is not null)
{
foreach (KeyValuePair<string, string> header in customHeaders)
{
result[header.Key] = header.Value; // Override default headers if same key
}
}
return result;
}
// IHttpClientAdapter implementation (without caching for non-GET operations)
Task<TResponse> IHttpClientAdapter.GetAsync<TResponse>(string requestUri, CancellationToken cancellationToken) =>
GetAsync<TResponse>(requestUri, cacheDuration: null, cancellationToken);
Task<TResponse> IHttpClientAdapter.GetAsync<TResponse>(
string requestUri, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
GetAsync<TResponse>(requestUri, headers, cacheDuration: null, cancellationToken);
Task<TResponse> IHttpClientAdapter.GetAsync<TResponse>(
Uri requestUri, CancellationToken cancellationToken) =>
GetAsync<TResponse>(requestUri, cacheDuration: null, cancellationToken);
Task<TResponse> IHttpClientAdapter.GetAsync<TResponse>(
Uri requestUri, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
GetAsync<TResponse>(requestUri, headers, cacheDuration: null, cancellationToken);
Task<HttpResponseMessage> IHttpClientAdapter.PostAsync<TRequest>(
string requestUri, TRequest content, CancellationToken cancellationToken) =>
PostAsync(requestUri, content, cancellationToken);
Task<HttpResponseMessage> IHttpClientAdapter.PostAsync<TRequest>(
string requestUri, TRequest content, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
PostAsync(requestUri, content, headers, cancellationToken);
Task<TResponse> IHttpClientAdapter.PostAsync<TRequest, TResponse>(
string requestUri, TRequest content, CancellationToken cancellationToken) =>
PostAsync<TRequest, TResponse>(requestUri, content, cancellationToken);
Task<TResponse> IHttpClientAdapter.PostAsync<TRequest, TResponse>(
string requestUri, TRequest content, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
PostAsync<TRequest, TResponse>(requestUri, content, headers, cancellationToken);
Task<TResponse> IHttpClientAdapter.PutAsync<TRequest, TResponse>(
string requestUri, TRequest content, CancellationToken cancellationToken) =>
PutAsync<TRequest, TResponse>(requestUri, content, cancellationToken);
Task<TResponse> IHttpClientAdapter.PutAsync<TRequest, TResponse>(
string requestUri, TRequest content, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
PutAsync<TRequest, TResponse>(requestUri, content, headers, cancellationToken);
Task<TResponse> IHttpClientAdapter.DeleteAsync<TResponse>(
string requestUri, CancellationToken cancellationToken) =>
DeleteAsync<TResponse>(requestUri, cancellationToken);
Task<TResponse> IHttpClientAdapter.DeleteAsync<TResponse>(
string requestUri, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
DeleteAsync<TResponse>(requestUri, headers, cancellationToken);
Task<HttpResponseMessage> IHttpClientAdapter.DeleteAsync(string requestUri, CancellationToken cancellationToken) =>
DeleteAsync(requestUri, cancellationToken);
Task<HttpResponseMessage> IHttpClientAdapter.DeleteAsync(
string requestUri, IDictionary<string, string> headers, CancellationToken cancellationToken) =>
DeleteAsync(requestUri, headers, cancellationToken);
}