/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ using System; using System.Management.Automation; using System.Net.Http; using System.Threading; using System.Threading.Tasks; namespace Microsoft.Rest.ClientRuntime { using NextDelegate = Func, Task>, Task>; using SignalDelegate = Func, Task>; public class CmdInfoHandler { private readonly string processRecordId; private readonly string parameterSetName; private readonly InvocationInfo invocationInfo; public CmdInfoHandler(string processRecordId, InvocationInfo invocationInfo, string parameterSetName) { this.processRecordId = processRecordId; this.parameterSetName = parameterSetName; this.invocationInfo = invocationInfo; } public Task SendAsync(HttpRequestMessage request, CancellationToken token, Action cancel, SignalDelegate signal, NextDelegate next) { request.Headers.Add("x-ms-client-request-id", processRecordId); request.Headers.Add("CommandName", invocationInfo?.InvocationName); request.Headers.Add("FullCommandName", invocationInfo?.MyCommand?.Name); request.Headers.Add("ParameterSetName", parameterSetName); // continue with pipeline. return next(request, token, cancel, signal); } } }