| | 1 | | using System; |
| | 2 | | using System.Net.Http; |
| | 3 | | using System.Threading; |
| | 4 | | using System.Threading.Tasks; |
| | 5 | |
|
| | 6 | | namespace Microsoft.Azure.OperationalInsights |
| | 7 | | { |
| | 8 | | internal class CustomDelegatingHandler : DelegatingHandler |
| | 9 | | { |
| 0 | 10 | | internal OperationalInsightsDataClient Client { get; set; } |
| | 11 | |
|
| | 12 | | internal const string InternalNameHeader = "csharpsdk"; |
| | 13 | |
|
| | 14 | | protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cance |
| | 15 | | { |
| 0 | 16 | | var appName = InternalNameHeader; |
| 0 | 17 | | if (!string.IsNullOrWhiteSpace(Client.NameHeader)) |
| | 18 | | { |
| 0 | 19 | | appName += $",{Client.NameHeader}"; |
| | 20 | | } |
| | 21 | |
|
| 0 | 22 | | request.Headers.Add("prefer", Client.Preferences.ToString()); |
| 0 | 23 | | request.Headers.Add("x-ms-app", appName); |
| 0 | 24 | | request.Headers.Add("x-ms-client-request-id", Client.RequestId ?? Guid.NewGuid().ToString()); |
| | 25 | |
|
| | 26 | | // Call the inner handler. |
| 0 | 27 | | var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); |
| | 28 | |
|
| 0 | 29 | | return response; |
| 0 | 30 | | } |
| | 31 | | } |
| | 32 | | } |