Skip to content

[Feature] buffering entire JSON response into memory when sending Http requests #47

@Meir017

Description

@Meir017

Is this your first time submitting a feature request?

  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing functionality

Describe the feature

when handling the response body of http requests, we should directly desrialize the body into the class without manually calling ReadAsStringAsync.

we should instead use the T? result = await response.Content.ReadFromJsonAsync<T>(); API as described here https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient#explore-http-valid-content-responses. this only works for JSON content which we are using here.

if (response.StatusCode is >= 200 and < 400)
{
var responseBody = await response.Raw.Content.ReadAsStringAsync();
try
{
return JsonUtils.Deserialize<ListImportsResponse>(responseBody)!;
}

Describe alternatives you've considered

No response

Who will this benefit?

performance and allocation

Are you interested in contributing this feature?

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions