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

HttpClient.GetStreamAsync raising HttpRequestException #9148

Open
1 of 3 tasks
roy-cohen273 opened this issue Jun 14, 2023 · 3 comments · May be fixed by #11103
Open
1 of 3 tasks

HttpClient.GetStreamAsync raising HttpRequestException #9148

roy-cohen273 opened this issue Jun 14, 2023 · 3 comments · May be fixed by #11103
Assignees
Labels
area-System.Net.Http Pri3 Indicates issues/PRs that are low priority untriaged New issue has not been triaged by the area owner ⌚ Not Triaged

Comments

@roy-cohen273
Copy link

Issue description

The docs for HttpClient.GetStreamAsync state that an HttpRequestException will be raised if:

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation (or timeout for .NET Framework only).

However, an HttpRequestException is also raised when the request completes with a non-success status code.

Target framework

  • .NET Core (3.1, 5, 6, 7)
  • .NET Framework
  • .NET Standard
dotnet --info output or About VS info
<replace>
@issues-automation issues-automation bot added the Pri3 Indicates issues/PRs that are low priority label Jun 14, 2023
@gewarren gewarren transferred this issue from dotnet/docs Jul 18, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 18, 2023
@ghost
Copy link

ghost commented Jul 18, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Issue description

The docs for HttpClient.GetStreamAsync state that an HttpRequestException will be raised if:

The request failed due to an underlying issue such as network connectivity, DNS failure, server certificate validation (or timeout for .NET Framework only).

However, an HttpRequestException is also raised when the request completes with a non-success status code.

Target framework

  • .NET Core (3.1, 5, 6, 7)
  • .NET Framework
  • .NET Standard
dotnet --info output or About VS info
<replace>
Author: roy-cohen273
Assignees: -
Labels:

area-System.Net, untriaged, Pri3, :watch: Not Triaged

Milestone: -

Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl

@MihaZupan
Copy link
Member

MihaZupan commented Mar 11, 2025

Copying from dotnet/runtime#113177 (comment)

We do see value in improving our documentation to:

  • Call out where we are using these checks ourselves and you can't control it, i.e. all HttpClient.Get{String/ByteArray/Stream/FromJson}Async helpers - HttpClient.GetStreamAsync raising HttpRequestException #9148.
  • Include a note along the lines of "consider checking that HttpResponseMessage.StatusCode exactly matches the expected value instead".
  • Consider improving indicates if the HTTP response was successful to include its definition of "successful". it already does in Returns: section.

@antonfirsov antonfirsov self-assigned this Mar 11, 2025
@antonfirsov antonfirsov linked a pull request Mar 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net.Http Pri3 Indicates issues/PRs that are low priority untriaged New issue has not been triaged by the area owner ⌚ Not Triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants