C
C#3mo ago
Ploot

✅ Per request timeout

Is there any way to control the timeout period of a HttpClient on the request side instead of from the client itself? It feels a little bizarre that a class that's recommended to only be instantiated once and shared across the app controls timeouts from the client
4 Replies
Sossenbinder
Sossenbinder3mo ago
I don't think there's a way to set it on a HttpRequestMessage, but you can just use a cancellationtoken on every httpclient method Pretty sure that's how the client implements the timeout itself as well anyways
IsNotNull
IsNotNull3mo ago
@Ploot @Sossenbinder that appears to be 100% accurate per the docs:
No description
IsNotNull
IsNotNull3mo ago
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-8.0#remarks
Ploot
Ploot3mo ago
That's a very strange design choice but thank you
Want results from more Discord servers?
Add your server