Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance StreamResponse handling and update dependencies #121

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stevejgordon
Copy link
Collaborator

Updated ResponseBuilderDefaults to include StreamResponse in SpecialTypes. Refactored SetBodyCoreAsync in DefaultResponseBuilder.cs for readability and removed unnecessary using statements. Modified RequestCoreAsync in HttpWebRequestInvoker.cs and BuildResponseAsync in InMemoryRequestInvoker.cs to handle StreamResponse types with proper disposal. Updated Elastic.Transport.csproj to reference System.Text.Json version 8.0.5.

Updated `ResponseBuilderDefaults` to include `StreamResponse` in `SpecialTypes`. Refactored `SetBodyCoreAsync` in `DefaultResponseBuilder.cs` for readability and removed unnecessary `using` statements. Modified `RequestCoreAsync` in `HttpWebRequestInvoker.cs` and `BuildResponseAsync` in `InMemoryRequestInvoker.cs` to handle `StreamResponse` types with proper disposal. Updated `Elastic.Transport.csproj` to reference `System.Text.Json` version `8.0.5`.
{
var settings = disableDirectStreaming ? _settingsDisableDirectStream : _settings;
var memoryStreamFactory = new TrackMemoryStreamFactory();
Copy link
Member

Choose a reason for hiding this comment

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

The purpose of this was also to ensure the memory stream factory returned memory streams get disposed properly. I think we should still test this.

How should DisableDirectStreaming: true and StreamResponse behave?

We should have a matrix test over

DisableDirectStreaming | Type of Response

That asserts both the stream of the response AND any memory streams return by the memory stream factory (the real implementation uses a shared pool so returns are very important)

Testing StreamResponse and StringResponse should suffice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's a good call out. I'll reintroduce something to cover these scenarios as well.

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