Skip to content

Instantly share code, notes, and snippets.

@alexssantos
Created February 15, 2023 23:55
Show Gist options
  • Save alexssantos/ac9cfa443bacac8ab8fd301e44cdc5d5 to your computer and use it in GitHub Desktop.
Save alexssantos/ac9cfa443bacac8ab8fd301e44cdc5d5 to your computer and use it in GitHub Desktop.
Obtendo um DelegatingHandler do tipo TimeoutHandler de um HttpClient.
private TimeoutHandler GetInnerTimeoutFromHandlerRecursivelyFrom(HttpClient client)
{
DelegatingHandler handlerIx = client
.GetType().BaseType
.GetField("_handler", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(client) as DelegatingHandler;
while (handlerIx != null && handlerIx.GetType() != typeof(TimeoutHandler))
{
handlerIx = (DelegatingHandler)handlerIx.InnerHandler;
}
return (TimeoutHandler)handlerIx;
}
@alexssantos
Copy link
Author

Obtendo um DelegatingHandler do tipo TimeoutHandler de um HttpClient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment