Skip to content
Snippets Groups Projects
Commit dc00234d authored by Benjamin Franzke's avatar Benjamin Franzke Committed by Susanne Moog
Browse files

[TASK] Adapt FAL dumpFile to use PSR-7 response objects

A new driver method streamFile() is added (specified
in a new, internal StreamableDriverInterface).
streamFile() returns a PSR-7 response which serves
the contents of the file.

Once this interface will be marked as public, third party drivers
will be allowed to return an own response (e.g. containing a redirect
to a CDN), providing full controls to headers. It also opens
possibilties for optimizations like X-SendFile (apache) or
X-Accell-Redirect (nginx) to be used by drivers.

We also add SelfEmittableStreamInterface (marked as internal) to support
the same fast file sending using readfile() – the interface provides
a hook which is called by the AbstractApplication in sendResponse.
That means that file contents do not need to be read into memory, stored
into a stream, and then read again, but can be piped to stdout by php
directly.

For all existing drivers backward compatibility is provided by
wrapping their dumpFileContents() method into a decorator stream which
calls dumpFileContents *when* the response is sent.
That means middlewares are able to prevent/stop/enhance
the response, but the driver method dumpFileContents is still used –
it's delayed until Application::sendResponse.

The dumpFileContents method of the ResourceStorage class
is now deprecated. ResourceStorage->streamFile() should be used instead.

Change-Id: I64e707c1f8350e409ff2505b98531b92b2936e02
Releases: master
Resolves: #83793
Reviewed-on: https://review.typo3.org/55585


Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: default avatarSusanne Moog <susanne.moog@typo3.org>
parent b6564a0a
Branches
Tags
Showing
with 406 additions and 10 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment