| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Core; |
| | 5 | | using Azure.Core.Pipeline; |
| | 6 | |
|
| | 7 | | namespace 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> |
| 230 | 18 | | 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> |
| 2416 | 25 | | internal bool RemoveClientRequestIdHeaders { get; set; } = false; |
| | 26 | |
|
| | 27 | | /// <inheritdoc /> |
| | 28 | | public override void OnSendingRequest(HttpMessage message) |
| | 29 | | { |
| 2304 | 30 | | base.OnSendingRequest(message); |
| 2304 | 31 | | message.Request.Headers.Remove(BatchConstants.XmsVersionName); |
| 2304 | 32 | | if (RemoveClientRequestIdHeaders) |
| | 33 | | { |
| 2304 | 34 | | message.Request.Headers.Remove(BatchConstants.XmsClientRequestIdName); |
| 2304 | 35 | | message.Request.Headers.Remove(BatchConstants.XmsReturnClientRequestIdName); |
| | 36 | | } |
| 2304 | 37 | | } |
| | 38 | | } |
| | 39 | | } |