Skip to content

Add Via header to passed-through requests in Kestrel engine. Closes #1948 - #1950

Merged
waldekmastykarz merged 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-via-header
Oct 21, 2026
Merged

waldekmastykarz merged 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-via-header

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Closes #1948

The Kestrel engine stopped adding the Via header to passed-through requests after AddProxyHeader was removed in the Kestrel migration (#1854).

This change restores the v3.3.1 behavior in PluginPipeline: when a watched request isn't answered by a plugin, the pipeline appends Via: <http-version> dev-proxy/<version> (for example, Via: 1.1 dev-proxy/4.0.0) after BeforeRequest runs. The header reaches the origin, and response-phase plugins, like the recorder and .http generator, see it too. An existing Via value is preserved. This also follows RFC 9110 §7.6.3.

Tests: added integration tests for the header being added and for appending to an existing Via. All test suites pass.

…otnet#1948

Restores the behavior from v3.3.1 (removed in the Kestrel migration):
watched requests that no plugin answers get 'Via: <http-version> dev-proxy/<version>'
appended after BeforeRequest, so it reaches the origin and response-phase
plugins see it. Required by RFC 9110 section 7.6.3.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 558c5c5b-c2bd-4fab-bab2-51e635519d65
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:11
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner October 21, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change matches the requested behavior, includes integration coverage, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Restores the Kestrel engine’s Via header for watched requests passed through to the origin, preserving existing values.

Changes:

  • Appends the proxy’s HTTP and product versions after request plugins run.
  • Adds integration tests for new and existing Via headers.
File Description
DevProxy.Proxy.Kestrel/​Internal/​PluginPipeline.cs Adds Via to passed-through requests.
DevProxy.Integration.Tests/​PlainHttpIntegrationTests.cs Tests header addition and preservation.
DevProxy.Integration.Tests/​FakeOrigin.cs Adds an endpoint that echoes Via values.

Review effort: Balanced

@waldekmastykarz
waldekmastykarz merged commit 37ddf57 into dotnet:main Oct 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants