Avoid duplicate response headers on Elysia 1.4.18 and earlier - #972
Open
dktsudgg wants to merge 1 commit into
Open
Avoid duplicate response headers on Elysia 1.4.18 and earlier#972dktsudgg wants to merge 1 commit into
dktsudgg wants to merge 1 commit into
Conversation
When a response has a body, the plugin returns the `response` object directly, so there is no need to copy the response's headers into Elysia's `set.headers`. Elysia already includes `response.headers` in the HTTP response on its own. In fact, on Elysia 1.4.18 and earlier, copying `response.headers` into `set.headers` and then returning the response causes the HTTP response headers to be duplicated. (This was fixed on Elysia's side in 1.4.19.) This change therefore moves the early return of the `response` object, for the case where a body exists, above the header copy so that the HTTP response headers are no longer duplicated. While this problem is partly due to the bug in Elysia 1.4.18 and earlier, this fix is expected to resolve it sufficiently, so it does not raise the project's minimum Elysia version, keeping the current Elysia version support range intact. Assisted-by: Claude Code:claude-fable-5
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #970.
@fedify/elysia'sfedify()plugin copies the federation response headers intoset.headersand then returns the sameResponseobject.When the response has a body, that
Responsealready carries its own headers,so on Elysia 1.4.18 and earlier(where Elysia merges
set.headersinto the returned response by appending unconditionally) every response header ends up duplicated.(for example :
Content-Type: application/activity+json, application/activity+json)Elysia 1.4.19 changed the merge to skip headers the response already has, which masks the bug, but the package still supports Elysia
^1.3.6, so users on 1.4.18 and earlier receive malformed federation responses that a strict ActivityPub peer can reject.This change moves the early
return response(the case where the response has a body) above the header copy,so the copy only runs on the bodyless path where a fresh
new Response(null, …)needs the headers.When there is a body the
Responseis returned untouched, so there is nothing for Elysia to merge back in, and the headers are no longer duplicated on any Elysia version.See #970 for the details.
Assisted-by: Claude Code:claude-fable-5