[TASK] Adapt FAL dumpFile to use PSR-7 response objects 85/55585/15
authorBenjamin Franzke <bfr@bus.de>
Wed, 2 Aug 2017 14:06:54 +0000 (16:06 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Sun, 30 Sep 2018 20:50:42 +0000 (22:50 +0200)
commitdc00234dffc9bf10fef06a88163da2f594e9f867
tree656d597a1926e924169753d46b7582a9aefb3a82
parentb6564a0a979352ee4b90c5c271ab9b02ff610abf
[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: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/core/Classes/Controller/FileDumpController.php
typo3/sysext/core/Classes/Http/AbstractApplication.php
typo3/sysext/core/Classes/Http/FalDumpFileContentsDecoratorStream.php [new file with mode: 0644]
typo3/sysext/core/Classes/Http/SelfEmittableLazyOpenStream.php [new file with mode: 0644]
typo3/sysext/core/Classes/Http/SelfEmittableStreamInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
typo3/sysext/core/Classes/Resource/Driver/StreamableDriverInterface.php [new file with mode: 0644]
typo3/sysext/core/Classes/Resource/Hook/FileDumpEIDHookInterface.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83793-FALResourceStorage-dumpFileContents.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php