< Summary

Class:Azure.Storage.Blobs.Specialized.RemoveVersionHeaderPolicy
Assembly:Azure.Storage.Blobs.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\RemoveVersionHeaderPolicy.cs
Covered lines:8
Uncovered lines:0
Coverable lines:8
Total lines:39
Line coverage:100% (8 of 8)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Shared()-100%100%
get_RemoveClientRequestIdHeaders()-100%100%
OnSendingRequest(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\RemoveVersionHeaderPolicy.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using Azure.Core;
 5using Azure.Core.Pipeline;
 6
 7namespace Azure.Storage.Blobs.Specialized
 8{
 9    /// <summary>
 10    /// The x-ms-version header needs to be stripped from batched
 11    /// sub-operations.
 12    /// </summary>
 13    internal class RemoveVersionHeaderPolicy : HttpPipelineSynchronousPolicy
 14    {
 15        /// <summary>
 16        /// Shared instance of the policy.
 17        /// </summary>
 23018        public static HttpPipelinePolicy Shared { get; } = new RemoveVersionHeaderPolicy();
 19
 20        /// <summary>
 21        /// Optionally remove ClientRequestId.  This is a workaround for test
 22        /// recordings which need repeatable x-ms-client-request-id values in
 23        /// the sub-operations.
 24        /// </summary>
 241625        internal bool RemoveClientRequestIdHeaders { get; set; } = false;
 26
 27        /// <inheritdoc />
 28        public override void OnSendingRequest(HttpMessage message)
 29        {
 230430            base.OnSendingRequest(message);
 230431            message.Request.Headers.Remove(BatchConstants.XmsVersionName);
 230432            if (RemoveClientRequestIdHeaders)
 33            {
 230434                message.Request.Headers.Remove(BatchConstants.XmsClientRequestIdName);
 230435                message.Request.Headers.Remove(BatchConstants.XmsReturnClientRequestIdName);
 36            }
 230437        }
 38    }
 39}