Skip to content

IHttpForwarder and cancellation #1542

@Tratcher

Description

@Tratcher

IHttpForwarder.SendAsync does not directly accept a CancellationToken to abort it. It supports canceling if the ForwarderRequestConfig.ActivityTimeout expires, or if HttpContext.RequestAborted triggers (client disconnect).
https://github.com/microsoft/reverse-proxy/blob/79c88ce07f9b88a283e10fc4cc45287b2efa6750/src/ReverseProxy/Forwarder/IHttpForwarder.cs#L25-L26

A customer that wanted to add their own cancellation condition did so by replacing HttpContext.RequestAborted. However, this caused an issue where they were leaking resources because they were no longer responding to the original RequestAborted token. The fix was to chain the two tokens.

Feedback: Having a CancellationToken parameter on IHttpForwarder.SendAsync would make this less error prone.

Metadata

Metadata

Assignees

Labels

Type: BugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions