Repository navigation
fix(http): make OverrideHeaders replace CORS and server headers - #62
Conversation
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| if (j == 0 && srContext.OverrideHeaders.ContainsKey ( incameHeader.Item1 )) | ||
| baseResponse.Headers.SetHeader ( incameHeader.Item1, incameHeader.Item2 [ j ] ); |
There was a problem hiding this comment.
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 👍 / 👎.
Documented behavior
HttpContext.OverrideHeadersis 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 fromSetCorsHeaders) were appended to, producing duplicates. For example, overridingAccess-Control-Allow-Originreturned bothhttps://good.exampleand the override value. Reproduced on the default and Cadente engines.Fix
In step 4 of
HandleContext, the first value of a header present inOverrideHeadersis written withSetHeader; remaining values and all other headers still useAppendHeader.ExtraHeadersand multi-value response headers are unchanged.Tests
OverrideHeadersReplaceCorsAndServerHeaders(default and Cadente) toBugFindingRegressionTests: singleAccess-Control-Allow-Origin, singleX-Powered-By, single overridden response header, andExtraHeadersstill adding a second value. It fails without the fix and passes with it on both engines.tests/Sisk.Corepasses locally on both engines.