| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Threading.Tasks; |
| | 6 | | using Azure.Core; |
| | 7 | | using Azure.Core.Pipeline; |
| | 8 | |
|
| | 9 | | namespace Azure.Storage.Blobs.Specialized |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// BatchPipelineTransport is an empty transport protocol that never sends |
| | 13 | | /// anything over the wire. It allows batch sub-operations to run through |
| | 14 | | /// a pipeline to and have policies like Authentication prepare the Request. |
| | 15 | | /// </summary> |
| | 16 | | internal class BatchPipelineTransport : HttpPipelineTransport |
| | 17 | | { |
| | 18 | | /// <summary> |
| | 19 | | /// We cache the original pipeline used to create the BlobBatchClient |
| | 20 | | /// so we can create the same type of Request objects. |
| | 21 | | /// </summary> |
| | 22 | | private readonly HttpPipeline _original; |
| | 23 | |
|
| | 24 | | /// <summary> |
| | 25 | | /// Creates a new instance of the <see cref="BatchPipelineTransport"/> |
| | 26 | | /// class. |
| | 27 | | /// </summary> |
| | 28 | | /// <param name="originalPipeline"> |
| | 29 | | /// The original pipeline used to create the BlobBatchClient. |
| | 30 | | /// </param> |
| 116 | 31 | | public BatchPipelineTransport(HttpPipeline originalPipeline) => |
| 116 | 32 | | _original = originalPipeline ?? throw new ArgumentNullException(nameof(originalPipeline)); |
| | 33 | |
|
| | 34 | | /// <inheritdoc /> |
| 2324 | 35 | | public override Request CreateRequest() => _original.CreateRequest(); |
| | 36 | |
|
| | 37 | | /// <inheritdoc /> |
| | 38 | | public override void Process(HttpMessage message) => |
| 1152 | 39 | | SetResponse(message); |
| | 40 | |
|
| | 41 | | #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously |
| | 42 | | /// <inheritdoc /> |
| | 43 | | public override async ValueTask ProcessAsync(HttpMessage message) => |
| 1152 | 44 | | SetResponse(message); |
| | 45 | | #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously |
| | 46 | |
|
| | 47 | | private static void SetResponse(HttpMessage message) => |
| 2304 | 48 | | message.Response = new MemoryResponse(); |
| | 49 | | } |
| | 50 | | } |