Skip to content

fix(http): make OverrideHeaders replace CORS and server headers - #62

Merged
CypherPotato merged 1 commit into
mainfrom
fix/override-headers-replace
Nov 12, 2026
Merged

CypherPotato merged 1 commit into
mainfrom
fix/override-headers-replace

Conversation

@CypherPotato

Copy link
Copy Markdown
Member

Documented behavior

HttpContext.OverrideHeaders is documented as headers which "will overwrite headers set by CORS, router response or request handlers".

Observed behavior

Only headers from the router response were replaced. Headers already written to the engine before the action (X-Request-Id, X-Powered-By, and CORS headers from SetCorsHeaders) were appended to, producing duplicates. For example, overriding Access-Control-Allow-Origin returned both https://good.example and the override value. Reproduced on the default and Cadente engines.

Fix

In step 4 of HandleContext, the first value of a header present in OverrideHeaders is written with SetHeader; remaining values and all other headers still use AppendHeader. ExtraHeaders and multi-value response headers are unchanged.

Tests

  • Added OverrideHeadersReplaceCorsAndServerHeaders (default and Cadente) to BugFindingRegressionTests: single Access-Control-Allow-Origin, single X-Powered-By, single overridden response header, and ExtraHeaders still adding a second value. It fails without the fix and passes with it on both engines.
  • tests/Sisk.Core passes locally on both engines.

OverrideHeaders only replaced headers in the router response, so headers already written to the engine (CORS, X-Powered-By, X-Request-Id) were duplicated instead of replaced. The first value of an overridden header now uses SetHeader on the engine.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T13:43:20.747290Z e7ca5a6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7ca5a6e79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +372 to +373
if (j == 0 && srContext.OverrideHeaders.ContainsKey ( incameHeader.Item1 ))
baseResponse.Headers.SetHeader ( incameHeader.Item1, incameHeader.Item2 [ j ] );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply overrides to empty responses

When a route returns null or an empty response, execution jumps to finishSending before reaching this override handling. The response may already contain CORS and server headers, so OverrideHeaders still cannot replace them on these 204 responses, despite being documented to replace headers in the final response. Apply overrides on that exit path as well.

Useful? React with 👍 / 👎.

@CypherPotato
CypherPotato merged commit 0e651e1 into main Nov 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant