Recursively collect delegate headers to include in fetch request#110
Closed
tleish wants to merge 1 commit intohotwired:mainfrom
Closed
Recursively collect delegate headers to include in fetch request#110tleish wants to merge 1 commit intohotwired:mainfrom
tleish wants to merge 1 commit intohotwired:mainfrom
Conversation
f3d413a to
9c8f35c
Compare
Contributor
Author
|
Updated code to support addition of |
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Feb 7, 2021
Closes hotwired#86 Closes hotwired#110 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
Contributor
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Feb 7, 2021
Closes hotwired#86 Closes hotwired#110 Recursively walk the tree of dependent FetchRequestDelegates so that they all have an opportunity to modify the fetch request headers. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Feb 7, 2021
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Feb 7, 2021
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit changes the `FetchRequest.headers` property to be `readonly` and created at constructor-time so that its values can be mutated prior to the request's submission. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
seanpdoyle
added a commit
that referenced
this pull request
Feb 12, 2021
Closes #86 Closes #110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit changes the `FetchRequest.headers` property to be `readonly` and created at constructor-time so that its values can be mutated prior to the request's submission. Testing adds listeners for `turbo:before-fetch-request` and `turbo:before-fetch-response` so that the event logs can drain. Co-authored-by: tleish <tleish@users.noreply.github.com>
seanpdoyle
added a commit
that referenced
this pull request
Apr 9, 2021
Closes #86 Closes #110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit introduces a readonly `FetchRequestHeaders` property created at constructor-time so that its values can be mutated prior to the request's submission. Co-authored-by: tleish <tleish@users.noreply.github.com>
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Apr 9, 2021
Closes hotwired#86 Closes hotwired#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit introduces a readonly `FetchRequestHeaders` property created at constructor-time so that its values can be mutated prior to the request's submission. Co-authored-by: tleish <tleish@users.noreply.github.com>
Challenge-Guy
pushed a commit
to Challenge-Guy/turbo-cfm1
that referenced
this pull request
Mar 8, 2025
Closes hotwired/turbo#86 Closes hotwired/turbo#110 When submitting a Form that is within a `<turbo-frame>` or targets a `<turbo-frame>`, ensure that the `Turbo-Frame` header is present. Since the constructive-style `FetchRequestDelegate.additionalHeadersForRequest()` was replaced by the mutative style `FetchRequestDelegate.prepareHeadersForRequest()`, this commit introduces a readonly `FetchRequestHeaders` property created at constructor-time so that its values can be mutated prior to the request's submission. Co-authored-by: tleish <tleish@users.noreply.github.com>
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.
Closes #86
When turbo sends a fetch, it uses the following method in
FetchRequestto get additional headers:When the
this.delegate=FrameController, the FrameController adds theTurbo-Frameheader to the request.TURBO-FRAME GET
For a GET form inside. a turbo-frame,
this.delegate=FrameController. So, form#GET requests include theTurbo-Frameheader.TURBO-FRAME NON-GET (e.g. POST/PUT/DELETE)
For a NON-GET form inside. a turbo-frame,
this.delegate=FrameController. Which means, noTurbo-Frameheader.The system does detect the turbo-frame, it just wraps it in FormSubmission and assigns FrameController as the delegate.
FormSubmission = { delegate: FrameController }Perhaps there are other nested delegate scenarios (e.g. ViewController). This update traverses delegates to collect all additionalHeadersForRequest. It also ensures that headers from the closest delegate relatives override headers from the most distance delegate relatives.