@@ -16,23 +16,34 @@ namespace A2A.Client.Services;
1616/// <summary>
1717/// Represents the default HTTP implementation of the <see cref="IA2AProtocolClient"/> interface
1818/// </summary>
19- /// <param name="options">The service used to access the current <see cref="A2AProtocolClientOptions"/></param>
20- /// <param name="httpClient">The service used to perform HTTP requests</param>
21- public class A2AProtocolHttpClient ( IOptions < A2AProtocolClientOptions > options , HttpClient httpClient )
22- : IA2AProtocolClient , IDisposable
19+ public class A2AProtocolHttpClient : IA2AProtocolClient , IDisposable
2320{
2421
2522 bool _disposed ;
2623
24+ /// <param name="options">The service used to access the current <see cref="A2AProtocolClientOptions"/></param>
25+ /// <param name="httpClient">The service used to perform HTTP requests</param>
26+ public A2AProtocolHttpClient ( IOptions < A2AProtocolClientOptions > options , HttpClient httpClient )
27+ {
28+ this . Options = options . Value ;
29+ this . HttpClient = httpClient ;
30+
31+ if ( this . Options . Authorization is not null )
32+ {
33+ var ( scheme , token ) = this . Options . Authorization ( ) ;
34+ this . HttpClient . DefaultRequestHeaders . Authorization = new ( scheme , token ) ;
35+ }
36+ }
37+
2738 /// <summary>
2839 /// Gets the current <see cref="A2AProtocolClientOptions"/>
2940 /// </summary>
30- protected A2AProtocolClientOptions Options { get ; } = options . Value ;
41+ protected A2AProtocolClientOptions Options { get ; }
3142
3243 /// <summary>
3344 /// Gets the service used to perform HTTP requests
3445 /// </summary>
35- protected HttpClient HttpClient { get ; } = httpClient ;
46+ protected HttpClient HttpClient { get ; }
3647
3748 /// <inheritdoc/>
3849 public virtual async Task < RpcResponse < Models . Task > > SendTaskAsync ( SendTaskRequest request , CancellationToken cancellationToken = default )
0 commit comments