forked from Azure/azure-sdk-for-net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add response read timeouts (Azure#10128)" (Azure#10168)
This reverts commit c4c10ac.
- Loading branch information
Showing
12 changed files
with
112 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
sdk/core/Azure.Core/src/Pipeline/Internal/BufferResponsePolicy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Core.Pipeline | ||
{ | ||
internal class BufferResponsePolicy : HttpPipelinePolicy | ||
{ | ||
protected BufferResponsePolicy() | ||
{ | ||
} | ||
|
||
public static HttpPipelinePolicy Shared { get; set; } = new BufferResponsePolicy(); | ||
|
||
public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
{ | ||
await ProcessNextAsync(message, pipeline).ConfigureAwait(false); | ||
|
||
if (message.BufferResponse) | ||
{ | ||
await BufferResponse(message, true).ConfigureAwait(false); | ||
} | ||
} | ||
|
||
public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
{ | ||
ProcessNext(message, pipeline); | ||
|
||
if (message.BufferResponse) | ||
{ | ||
BufferResponse(message, false).EnsureCompleted(); | ||
} | ||
} | ||
|
||
private static async ValueTask BufferResponse(HttpMessage message, bool async) | ||
{ | ||
if (message.Response.ContentStream != null && !message.Response.ContentStream.CanSeek) | ||
{ | ||
Stream responseContentStream = message.Response.ContentStream; | ||
var bufferedStream = new MemoryStream(); | ||
if (async) | ||
{ | ||
await responseContentStream.CopyToAsync(bufferedStream).ConfigureAwait(false); | ||
} | ||
else | ||
{ | ||
responseContentStream.CopyTo(bufferedStream); | ||
} | ||
responseContentStream.Dispose(); | ||
bufferedStream.Position = 0; | ||
message.Response.ContentStream = bufferedStream; | ||
} | ||
} | ||
} | ||
} |
128 changes: 0 additions & 128 deletions
128
sdk/core/Azure.Core/src/Pipeline/Internal/ReadTimeoutStream.cs
This file was deleted.
Oops, something went wrong.
129 changes: 0 additions & 129 deletions
129
sdk/core/Azure.Core/src/Pipeline/Internal/ResponseBodyPolicy.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.