Project

General

Profile

Actions

Feature #19034

closed

Direct HTTP redirections from QFQ

Added by Krzysztof Putyra 10 days ago. Updated 7 days ago.

Status:
Closed
Priority:
High
Assignee:
Krzysztof Putyra
Target version:
Start date:
07.07.2024
Due date:
08.07.2024
% Done:

0%

Estimated time:
Discuss:
Prio Planung:
No
Vote:
KP

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.

Actions #1

Updated by Krzysztof Putyra 10 days ago

Parameters
  • location URL (required)
  • HTTP status code (optional with a default value)
Syntax variants
  1. SELECT '...|r:9|h:307' AS _link
    • no new special column
    • the link column gets even more complicated
  2. 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
  3. 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
  1. 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.
  2. 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

Actions #2

Updated by Krzysztof Putyra 10 days ago

  • Tracker changed from Support to Feature
Actions #3

Updated by Krzysztof Putyra 10 days ago

  • Priority changed from Normal to High
Actions #4

Updated by Krzysztof Putyra 10 days ago

  • Subject changed from Drect HTTP redirections from QFQ to Direct HTTP redirections from QFQ
Actions #5

Updated by Krzysztof Putyra 10 days ago

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
Actions #6

Updated by Krzysztof Putyra 8 days ago

  • Status changed from In Progress to Closed
Actions #7

Updated by Carsten Rose 7 days ago

  • Target version changed from CodingWeek2024 to 24.7.0
Actions

Also available in: Atom PDF