import { HttpOperationResponse } from "../httpOperationResponse" ; import * as utils from "../util/utils" ; import { WebResourceLike } from "../webResource" ; import { BaseRequestPolicy , RequestPolicy , RequestPolicyFactory , RequestPolicyOptionsLike , } from "./requestPolicy" ; export function generateClientRequestIdPolicy ( requestIdHeaderName = "x-ms-client-request-id" ) { return { create : ( nextPolicy , options ) => { return new GenerateClientRequestIdPolicy ( nextPolicy , options , requestIdHeaderName ) ; } , } ; } export class GenerateClientRequestIdPolicy extends BaseRequestPolicy { constructor ( nextPolicy , options , private _requestIdHeaderName ) { super ( nextPolicy , options ) ; } public sendRequest ( request ) { if ( ! request . headers . contains ( this . _requestIdHeaderName ) ) { request . headers . set ( this . _requestIdHeaderName , utils . generateUuid ( ) ) ; } return this . _nextPolicy . sendRequest ( request ) ; } }