@@ -19,7 +19,7 @@ public record struct Registry(Uri BaseUri)
19
19
20
20
public async Task < Image > GetImageManifest ( string name , string reference )
21
21
{
22
- using HttpClient client = GetClient ( ) ;
22
+ HttpClient client = GetClient ( ) ;
23
23
24
24
var response = await client . GetAsync ( new Uri ( BaseUri , $ "/v2/{ name } /manifests/{ reference } ") ) ;
25
25
@@ -70,7 +70,7 @@ public async Task<string> DownloadBlob(string name, Descriptor descriptor)
70
70
71
71
// No local copy, so download one
72
72
73
- using HttpClient client = GetClient ( ) ;
73
+ HttpClient client = GetClient ( ) ;
74
74
75
75
var response = await client . GetAsync ( new Uri ( BaseUri , $ "/v2/{ name } /blobs/{ descriptor . Digest } ") , HttpCompletionOption . ResponseHeadersRead ) ;
76
76
@@ -101,7 +101,7 @@ public async Task Push(Layer layer, string name, Action<string> logProgressMessa
101
101
102
102
private readonly async Task UploadBlob ( string name , string digest , Stream contents )
103
103
{
104
- using HttpClient client = GetClient ( ) ;
104
+ HttpClient client = GetClient ( ) ;
105
105
106
106
if ( await BlobAlreadyUploaded ( name , digest , client ) )
107
107
{
@@ -155,7 +155,14 @@ private readonly async Task<bool> BlobAlreadyUploaded(string name, string digest
155
155
return false ;
156
156
}
157
157
158
+ private static HttpClient _client = CreateClient ( ) ;
159
+
158
160
private static HttpClient GetClient ( )
161
+ {
162
+ return _client ;
163
+ }
164
+
165
+ private static HttpClient CreateClient ( )
159
166
{
160
167
var clientHandler = new AuthHandshakeMessageHandler ( new HttpClientHandler ( ) { UseDefaultCredentials = true } ) ;
161
168
HttpClient client = new ( clientHandler ) ;
@@ -177,7 +184,7 @@ public async Task Push(Image x, string name, string? tag, string baseName, Actio
177
184
{
178
185
tag ??= "latest" ;
179
186
180
- using HttpClient client = GetClient ( ) ;
187
+ HttpClient client = GetClient ( ) ;
181
188
var reg = this ;
182
189
await Task . WhenAll ( x . LayerDescriptors . Select ( async descriptor => {
183
190
string digest = descriptor . Digest ;
0 commit comments