Feature #19034
closed
Direct HTTP redirections from QFQ
Added by Krzysztof Putyra 10 days ago.
Updated 7 days ago.
Assignee:
Krzysztof Putyra
Description
Currently a redirection is achieved with a JavaScript code. This has the following drawbacks:
- no redirection happen if JavaScript is disabled
- the whole page must be rendered by the server and by the browser before a redirection triggers
A better approach is to ask Typo3 to immediately send a 30x HTTP response with a location header.
This feature will improve
- several redirections on SeminarLive page
- user authentication via QFQ
Keeping in mind a future migration to a different template engine, the code code should be template agnostic.
Parameters
- location URL (required)
- HTTP status code (optional with a default value)
Syntax variants
SELECT '...|r:9|h:307' AS _link
- no new special column
- the
link
column gets even more complicated
SELECT 'l:{{&link:R}}|c:307' AS _httpRedirect
- special column makes it easy to spot
- the link must be created before if sip parameters are to be used
SELECT '...' AS '_link|_httpRedirect(307)'
- relies on parameters in brackets (#17265) and interpreting pipe-separated columns as processors (#17295)
- this is the cleanest syntax in my opinion
Currently the best choice seems to be 1. with 3. an improvement once the additional features are implemented.
HTTP code
Code |
Type |
What to be cached |
2nd request method |
301 |
Permanent |
The final URL |
may be changed |
308 |
Permanent |
The final URL |
cannot be changed |
302 |
Temporary |
The original URL |
may be changed |
307 |
Temporary |
The original URL |
cannot be changed |
303 |
Temporary |
The original URL |
must be changed to GET |
Notes
- Codes 307 and 308 were introduces after 301 and 302 to remove the ambiguity in handling the redirections: in case of 301 and 302 the specification said nothing about the request method for the second request and some user agents switches from POST to GET.
- 303 usually follows POST and PUT requests to deliver a page with results of an action. In such case repeating the POST or PUT request makes no sense and might be even confusing - the form is no longer visible.
Source: https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
- Tracker changed from Support to Feature
- Priority changed from Normal to High
- Subject changed from Drect HTTP redirections from QFQ to Direct HTTP redirections from QFQ
Implemented:
- functionality in Link class using the first syntax
- rendering mode 9 triggers an exception RedirectResponse
- the exception is catched by QfqController and converted to PropagateResponseException to make Typo3 trigger the redirection
- default HTTP code: 303
- unit tests for the Link class
- no unit test for QfqController, but the functionality has been directed on a test website
- updated documentation
- Status changed from In Progress to Closed
- Target version changed from CodingWeek2024 to 24.7.0
Also available in: Atom
PDF