[FEATURE] Allow multiple HTTP headers of the same type in TS 14/27814/6
authorMarco Huber <mhuber84@web.de>
Mon, 24 Feb 2014 13:01:58 +0000 (14:01 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 3 Jan 2015 17:13:14 +0000 (18:13 +0100)
Allows multiple HTTP headers of the same type in
config.additionalHeaders by extending the configuration
possibilities:

mypage.config.additionalHeaders {
10 {
#the header string
header = WWW-Authenticate: Negotiate

#replace previous headers with the same name
                #optional, default is 1 (yes)
                replace = 0

                #force the HTTP response code
#optional
                httpResponseCode = 401
}
}

See also: http://php.net/header

Resolves: #56236
Releases: master
Change-Id: I25b4c755459b3ad718624426a32f217055c189e5
Reviewed-on: http://review.typo3.org/27814
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-56236-Multiple-HTTP-Headers-In-Frontend.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-56236-Multiple-HTTP-Headers-In-Frontend.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-56236-Multiple-HTTP-Headers-In-Frontend.rst
new file mode 100644 (file)
index 0000000..1647082
--- /dev/null
@@ -0,0 +1,36 @@
+===========================================================================
+Feature: #56236 - Multiple HTTP headers of the same type in Frontend Output
+===========================================================================
+
+Description
+===========
+
+It is now possible to use ``config.additionalHeaders`` as a TypoScript array object to add multiple headers
+at the same time
+
+Usage:
+
+::
+       config.additionalHeaders {
+               10 {
+                       # the header string
+                       header = WWW-Authenticate: Negotiate
+
+                       # replace previous headers with the same name
+            # optional, default is "on"
+                       replace = 0
+
+                       # optional, force the HTTP response code
+                       httpResponseCode = 401
+               }
+               # always set cache headers to private, overwriting the sophisticated TYPO3 option
+               20.header = Cache-control: Private
+       }
+
+See also: http://php.net/header
+
+Impact
+======
+
+The previous option ``config.additionalHeaders = X-Header: ABC|X-Header2: DEF`` is deprecated in favor of the more
+flexible solution.
index ac513fe..f100272 100644 (file)
@@ -3619,11 +3619,23 @@ class TypoScriptFrontendController {
                // Set headers, if any
                if (!empty($this->config['config']['additionalHeaders'])) {
                        $headerArray = explode('|', $this->config['config']['additionalHeaders']);
+                       GeneralUtility::deprecationLog('The TypoScript option "config.additionalHeaders" has been deprecated with TYPO3 CMS 7, and will be removed with CMS 8, please use the more flexible syntax config.additionalHeaders.10... to separate each header value.');
                        foreach ($headerArray as $headLine) {
                                $headLine = trim($headLine);
                                header($headLine);
                        }
                }
+               if (is_array($this->config['config']['additionalHeaders.'])) {
+                       ksort($this->config['config']['additionalHeaders.']);
+                       foreach ($this->config['config']['additionalHeaders.'] as $options) {
+                               header(
+                                       trim($options['header']),
+                                       // "replace existing headers" is turned on by default, unless turned off
+                                       ($options['replace'] === '0' ? FALSE : TRUE),
+                                       ((int)$options['httpResponseCode'] ?: NULL)
+                               );
+                       }
+               }
                // Send appropriate status code in case of temporary content
                if ($this->tempContent) {
                        $this->addTempContentHttpHeaders();