| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Threading.Tasks; |
| | | 6 | | |
| | | 7 | | namespace Azure.Core.Pipeline |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Represents a <see cref="HttpPipelinePolicy"/> that doesn't do any asynchronous or synchronously blocking operati |
| | | 11 | | /// </summary> |
| | | 12 | | public abstract class HttpPipelineSynchronousPolicy : HttpPipelinePolicy |
| | | 13 | | { |
| | | 14 | | /// <inheritdoc /> |
| | | 15 | | public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) |
| | | 16 | | { |
| | 2436 | 17 | | OnSendingRequest(message); |
| | 2436 | 18 | | ProcessNext(message, pipeline); |
| | 2430 | 19 | | OnReceivedResponse(message); |
| | 2430 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) |
| | | 24 | | { |
| | 2506 | 25 | | OnSendingRequest(message); |
| | 2506 | 26 | | await ProcessNextAsync(message, pipeline).ConfigureAwait(false); |
| | 2500 | 27 | | OnReceivedResponse(message); |
| | 2500 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Method is invoked before the request is sent. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <param name="message">The <see cref="HttpMessage" /> containing the request.</param> |
| | 8 | 34 | | public virtual void OnSendingRequest(HttpMessage message) { } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Method is invoked after the response is received. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <param name="message">The <see cref="HttpMessage" /> containing the response.</param> |
| | 4928 | 40 | | public virtual void OnReceivedResponse(HttpMessage message) { } |
| | | 41 | | } |
| | | 42 | | } |