Skip to content

Replace ReadAsStringAsync with ReadAsStreamAsync #7

@Ggeorgi98

Description

@Ggeorgi98

The size of the HTTP responses can differ and we can get very huge responses. If we store them as a string, they can end up in the Large object heap which can lead to some performance issues most related to the memory.

var response = await _httpClient.SendAsync(request);
return await response.Content.ReadAsStringAsync();

For reference:

  • 'You're (probably still) using HttpClient wrong and it is destabilizing your software', Josef Ottosson - link - you can check the section with the benchmarks and see that ReadAsStreamAsync has performed better than ReadAsStringAsync.

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