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

IFlurlClientBuilder.AddMiddleware cuts the chain of delegating handlers #821

Open
andreikarkkanen opened this issue Apr 25, 2024 · 1 comment
Labels

Comments

@andreikarkkanen
Copy link

Flurl.Http 4.0.2

The passing delegating handler, is typically a chain of handlers. However, AddMiddleware assigns the outer handler to the very first element in the chain of handlers, like this:

foreach (var middleware in Enumerable.Reverse(_addMiddleware).Select(create => create())) 
{
	middleware.InnerHandler = outerHandler;
	outerHandler = middleware;
}

This behavior disrupts the intended sequence of handlers in the chain. A better approach would be for AddMiddleware to follow the chain to its end before making any assignments.

while (middleware.InnerHandler is DelegatingHandler delegatingHandler)
{
    middleware = delegatingHandler;
}
middleware.InnerHandler = outerHandler;
@tmenier
Copy link
Owner

tmenier commented May 6, 2024

Thanks for reporting, appears to be legit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

2 participants