C
C#4mo 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
Sossenbinder4mo 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
IsNotNull4mo ago
@Ploot @Sossenbinder that appears to be 100% accurate per the docs:
No description
IsNotNull
IsNotNull4mo ago
https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-8.0#remarks
Ploot
PlootOP4mo ago
That's a very strange design choice but thank you
Want results from more Discord servers?
Add your server