< Summary

Class:Azure.Storage.StorageRequestValidationPipelinePolicy
Assembly:Azure.Storage.Files.DataLake
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageRequestValidationPipelinePolicy.cs
Covered lines:9
Uncovered lines:0
Coverable lines:9
Total lines:43
Line coverage:100% (9 of 9)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
OnReceivedResponse(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Common\src\Shared\StorageRequestValidationPipelinePolicy.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Linq;
 6using Azure.Core;
 7using Azure.Core.Pipeline;
 8
 9namespace Azure.Storage
 10{
 11    /// <summary>
 12    /// Pipeline policy to verify x-ms-client-request-id and x-ms-client-return-request-id
 13    /// headers that are echoed back from a request match.
 14    /// </summary>
 15    internal class StorageRequestValidationPipelinePolicy : HttpPipelineSynchronousPolicy
 16    {
 17        private readonly ClientDiagnostics _clientDiagnostics;
 18
 19        /// <summary>
 20        /// Create a new StorageRequestValidationPipelinePolicy
 21        /// </summary>
 309422        public StorageRequestValidationPipelinePolicy(ClientOptions options)
 23        {
 309424            _clientDiagnostics = new ClientDiagnostics(options);
 309425        }
 26
 27        /// <summary>
 28        /// Verify x-ms-client-request-id and x-ms-client-return-request-id headers matches as
 29        /// x-ms-client-return-request-id is an echo of x-mis-client-request-id.
 30        /// </summary>
 31        /// <param name="message">The message that was sent</param>
 32        public override void OnReceivedResponse(HttpMessage message)
 33        {
 1268634            if (message.HasResponse &&
 1268635                message.Request.Headers.TryGetValue(Constants.HeaderNames.ClientRequestId, out var original) &&
 1268636                message.Response.Headers.TryGetValues(Constants.HeaderNames.ClientRequestId, out var echo) &&
 1268637                !String.Equals(original, echo.First(), StringComparison.OrdinalIgnoreCase))
 38            {
 1239                throw Errors.ClientRequestIdMismatch(_clientDiagnostics, message.Response, echo.First(), original);
 40            }
 1267441        }
 42    }
 43}

Methods/Properties

.ctor(...)
OnReceivedResponse(...)