Skip to content

Remove the dead HttpContext.Items read from ParseContentType - #10453

Merged
glen-84 merged 1 commit into
mainfrom
gai/remove-dead-content-type-cache-read
Sep 30, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/remove-dead-content-type-cache-read

Conversation

@glen-84

@glen-84 glen-84 commented Sep 30, 2026

Copy link
Copy Markdown
Member

Summary

  • ParseContentType opened by looking up HttpContext.Items["RequestContentType"], a key nothing has written since Add Fusion Transport Layer #8410 moved the method into HttpContextExtensions. The lookup never hit, and on a request where nothing else had touched Items it created the Items feature: 48 bytes on every POST, QUERY, and multipart request on Kestrel.
  • Writing the key instead would not pay off. A cache hit (about 11 ns) costs more than the parse it skips (4 to 10 ns, at most two case-insensitive span comparisons), no request calls the method more than twice, and the write allocates the backing dictionary (264 bytes per request).
  • No response changes. The lookup also honored the key when application code set it before MapGraphQL, which was never documented.

Test plan

  • HotChocolate.AspNetCore.Tests and HotChocolate.Fusion.AspNetCore.Tests pass on net10.0. The Fusion gateway runs the same request middlewares.
  • Allocations and per-call timings were measured inside Kestrel requests on .NET 11 RC 1.

Copilot AI lite review requested due to automatic review settings September 30, 2026 10:55

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.

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

What changed in this PR

Removes the unused HttpContext.Items lookup from ParseContentType, reducing request allocations while preserving content-type handling.

Changes:

  • Parses ContentType directly.
  • Preserves JSON, multipart, and query handling.
File Summary
src/​HotChocolate/​AspNetCore/​src/​AspNetCore.Pipeline/​Extensions/​HttpContextExtensions.cs Removes the obsolete Items lookup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@glen-84
glen-84 merged commit ea01dd6 into main Sep 30, 2026
159 checks passed
@glen-84
glen-84 deleted the gai/remove-dead-content-type-cache-read branch September 30, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants