Skip to content

Conversation

@annelo-msft
Copy link
Owner

Investigation into Azure#41080

public partial class HttpClientPipelineTransport
{
private class HttpPipelineResponse : PipelineResponse
private class HttpClientPipelineResponse : PipelineResponse
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this type

_httpResponseContent = _httpResponse.Content;

// Don't let anyone dispose the content, which is used by headers.
_httpResponse.Content = null;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this into the constructor

{
var httpResponse = _httpResponse;
httpResponse?.Dispose();
// The transport is responsible for disposing the HttpResponseMessage.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move where this happens?

{
message.Response.ContentStream = contentStream;
}
responseMessage.Dispose();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dispose this in the transport instead of in the response

await message.Response!.UpdateContentAsync(message.BufferResponse, userToken, joinedTokenSource).ConfigureAwait(false);
}

if (!message.BufferResponse)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logic into Response so transport just makes a simple call to response.TryBufferContent(message.BufferContent)

internal class HttpClientResponseHeaders : PipelineResponseHeaders
{
private readonly HttpResponseMessage _httpResponse;
private readonly HttpHeaders _httpHeaders;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't store the whole response message, just the part we need

#endif
#endregion

private static IEnumerable<KeyValuePair<string, IEnumerable<string>>> GetHeadersListValues(HttpHeaders headers, HttpContent? content)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this code, which is never used


protected virtual void SetIsErrorCore(bool isError) => _isError = isError;

internal TimeSpan NetworkTimeout { get; set; } = ClientPipeline.DefaultNetworkTimeout;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this initialization?


MemoryStream bufferStream = new();

// TODO: Come back and optimize this - for now, just a POC.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want to optimize the implementation

/// <remarks>
/// Throws <see cref="InvalidOperationException"/> when <see cref="PipelineResponse.ContentStream"/> is not a <see cref="MemoryStream"/>.
/// </remarks>
public new virtual BinaryData Content => base.Content;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this as we no longer need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants