@@ -20,7 +20,8 @@ namespace Core.Arango.Transport;
20
20
/// </summary>
21
21
public class ArangoHttpTransport ( IArangoConfiguration configuration ) : IArangoTransport
22
22
{
23
- private static readonly HttpClient DefaultHttpClient = new ( ) ;
23
+ static readonly HttpClient DefaultHttpClient = new ( ) ;
24
+ HttpClient Client => configuration . HttpClient ?? DefaultHttpClient ;
24
25
string _auth = "" ;
25
26
DateTime _authValidUntil = DateTime . MinValue ;
26
27
/// <inheritdoc />
@@ -73,9 +74,8 @@ public async Task<T> SendAsync<T>(HttpMethod m, string url, object body = null,
73
74
}
74
75
else
75
76
req . Headers . Add ( HttpRequestHeader . ContentLength . ToString ( ) , "0" ) ;
76
- var httpClient = DefaultHttpClient ;
77
- SetBasicAuth ( httpClient ) ;
78
- using var res = await httpClient . SendAsync ( req , cancellationToken ) . ConfigureAwait ( false ) ;
77
+ SetBasicAuth ( Client ) ;
78
+ using var res = await Client . SendAsync ( req , cancellationToken ) . ConfigureAwait ( false ) ;
79
79
80
80
if ( ! res . IsSuccessStatusCode )
81
81
if ( throwOnError )
@@ -121,9 +121,8 @@ public async Task<object> SendAsync(Type type, HttpMethod m, string url, object
121
121
}
122
122
else
123
123
req . Headers . Add ( HttpRequestHeader . ContentLength . ToString ( ) , "0" ) ;
124
- var httpClient = DefaultHttpClient ;
125
- SetBasicAuth ( httpClient ) ;
126
- using var res = await httpClient . SendAsync ( req , cancellationToken ) . ConfigureAwait ( false ) ;
124
+ SetBasicAuth ( Client ) ;
125
+ using var res = await Client . SendAsync ( req , cancellationToken ) . ConfigureAwait ( false ) ;
127
126
128
127
if ( ! res . IsSuccessStatusCode )
129
128
if ( throwOnError )
@@ -149,9 +148,8 @@ public async Task<HttpContent> SendContentAsync(HttpMethod m, string url, HttpCo
149
148
using var req = new HttpRequestMessage ( m , configuration . Server + url ) ;
150
149
ApplyHeaders ( transaction , auth , req , headers ) ;
151
150
req . Content = body ;
152
- var httpClient = DefaultHttpClient ;
153
- SetBasicAuth ( httpClient ) ;
154
- using var res = await httpClient . SendAsync ( req , cancellationToken ) ;
151
+ SetBasicAuth ( Client ) ;
152
+ using var res = await Client . SendAsync ( req , cancellationToken ) ;
155
153
156
154
if ( ! res . IsSuccessStatusCode && throwOnError )
157
155
{
0 commit comments