Skip to content

fix(http): align default middleware order - #884

Merged
Vincent Biret (baywet) merged 2 commits into
mainfrom
fix/http-middleware-order
Nov 24, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
mainfrom
fix/http-middleware-order

Conversation

@baywet

@baywet Vincent Biret (baywet) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Align the existing default HTTP handlers and both handler type lists with docs: standardize native HTTP middleware order microsoftgraph/msgraph-sdk-design#124. Redirect wraps retry, and headers and body inspection run closest to the transport.
  • Keep authorization middleware in the bearer-token factory overload only. Do not answer a claims challenge from another origin, and keep .NET Framework redirects in middleware rather than letting WinHTTP follow them.
  • Reset the retry attempt header for each redirect hop. Keep the existing transport decompression and do not add unavailable middleware.

Validation

  • .NET 10 HTTP test project: 399 passed.
  • .NET Framework factory tests (net472 target): 17 passed.
  • dotnet format --verify-no-changes passed for the changed files in both HTTP projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e625fa94-4ae9-464b-8e28-fddf64a8999d
@baywet
Vincent Biret (baywet) requested a review from a team as a code owner November 24, 2026 15:22
Copilot AI balanced review requested due to automatic review settings November 24, 2026 15:22

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.

🟡 Changes recommended

Disabling WinHTTP redirects exposes incorrect relative-Location resolution for .NET Framework callers; targets must resolve against the full original request URI, with query-only and path-relative regression tests added.

1 open issue
What changed in this PR

Aligns Kiota’s default HTTP middleware order with the SDK design, keeping redirect, retry, inspection, and authorization behavior consistent.

Changes:

  • Reorders default handlers and both handler type lists so redirect wraps retry and inspection runs nearest the transport.
  • Restricts claims-challenge authentication to the original origin, disables WinHTTP automatic redirects, and resets retry headers between redirect hops.
  • Documents the pipeline and adds factory tests for ordering, redirect behavior, and authorization boundaries.
File Description
tests/​http/​httpClient/​KiotaClientFactoryTests.cs Adds pipeline ordering, redirect, retry, and claims-challenge tests.
src/​http/​httpClient/​README.md Documents middleware order and authorization behavior.
src/​http/​httpClient/​Middleware/​RetryHandler.cs Makes the retry header constant available internally.
src/​http/​httpClient/​Middleware/​RedirectHandler.cs Clears the retry attempt header for each redirect hop.
src/​http/​httpClient/​Middleware/​Options/​RedirectHandlerOption.cs Extracts a shared same-origin comparison.
src/​http/​httpClient/​Middleware/​AuthorizationHandler.cs Prevents cross-origin claims-challenge authentication.
src/​http/​httpClient/​KiotaClientFactory.cs Aligns handler ordering and disables WinHTTP automatic redirects.

Review effort: Balanced

@github-code-quality

github-code-quality Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main a7ad03e fix/http-middleware-... b34da76 +/-
85% 85% 0%
View coverage of the 3 most impacted files.
File main a7ad03e fix/http-middleware-... b34da76 +/-
D:\a\kiota-dotn...irectHandler.cs 93% 92% -1%
D:\a\kiota-dotn...ationHandler.cs 90% 91% +1%
D:\a\kiota-dotn...lientFactory.cs 68% 95% +27%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 24, 2026 15:47 UTC

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e625fa94-4ae9-464b-8e28-fddf64a8999d
Copilot AI balanced review requested due to automatic review settings November 24, 2026 15:36

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

No active review issues remain for the middleware ordering and redirect/authentication boundary changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Nov 24, 2026
@github-project-automation github-project-automation Bot moved this to In Progress 🚧 in Kiota Nov 24, 2026
Merged via the queue into main with commit 43253d8 Nov 24, 2026
8 checks passed
@baywet
Vincent Biret (baywet) deleted the fix/http-middleware-order branch November 24, 2026 19:26
@github-project-automation github-project-automation Bot moved this from In Progress 🚧 to Done ✔️ in Kiota Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

3 participants