-
-
Notifications
You must be signed in to change notification settings - Fork 21
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.Send (synchronous API) is not intercepted #478
Comments
Hi there and welcome to this repository! A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it. |
Hi @Timovzl, I'll look into the issue tonight. |
@FantasticFiasco I have created a PR to help speed things along. I did not have time to change the commit message to adhere to your guidelines 100%, so feel free to use the PR as you see fit. If you prefer to reject it and use it for inspiration only, perfect. I hope it's of help. |
Release v2.1.1 is now live, thank you so much for your contribution! |
My pleasure. I'm glad you are providing this library, as AWS signing turned out to be much more complex than anticipated. I just realized that with this addition, the package provides something unique: Truly synchronous access to AWS resources over HTTPS, without resorting to sync-over-async. Unique because, for example, all available ElasticSearch client packages use |
If you're happy, I'm happy 😀 It was after all a feature you yourself implemented, which to many open source project is rare and extremely valuable! I might update |
Describe the bug
The package correctly intercepts
HttpClient.SendAsync()
(and all the extension methods that invoke it, such asGetAsync()
orPostAsync()
), adding the Authorization header and such.However, the synchronous API is not properly intercepted.
HttpClient.Send()
does not cause the necessary headers to be added.Presumably, this is because this API was added in .NET 5. A new target would be needed.
To Reproduce
In .NET 5, create an
HttpClient
configured with this package's message handler, which normally signs any request made. Construct anHttpRequestMessage
and send it usingHttpClient.Send()
. After sending, confirm the absence of headers on theHttpRequestMessage
. Compare this toHttpClient.SendAsync()
, which causes the headers to be added as expected.Expected behavior
On send, the necessary headers are expected to be added to the
HttpRequestMessage
, such as the Authorization header.Environment
.NET 5.
Additional context
It would probably make sense to include .NET 5 as an additional target platform, so that the synchrous API can be
interceptedoverridden.There are significant use cases for the HttpClient's synchronous API. The original proposal contains extensive explanations and discussions about it. It was finally added in .NET 5.
Stephen Toub explains:
My own experience confirms that thread pool exhaustion happens extremely quickly with sync-over-async - much more so than one might expect. This limits the number of simultaneous operations to a fraction of what is achievable with a purely synchronous API.
In a .NET 5 preview blog, Stephen Toub further summarizes the addition of a synchronous API:
The text was updated successfully, but these errors were encountered: