[BUGFIX] Reallow custom request context in getUrl 08/46208/3
authorSascha Egerer <sascha@sascha-egerer.de>
Sun, 24 Jan 2016 11:23:40 +0000 (12:23 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 15 Feb 2016 12:13:36 +0000 (13:13 +0100)
In b4813ddb55ab789ddd13e02234f147a44d2af1ed an patch
has been introduced which respects the default stream context
when requesting urls. But the change prevents that custom
stream options (headers) can be set.

The default stream context should be used and extended by the
given custom headers.

Change-Id: I6ec6d23498e194055cefc1c6c63db7c161ee03c6
Resolves: #72907
Related: #70374
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/46208
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Claus Due <claus@phpmind.net>
Reviewed-by: Ralf Merz <info@merzilla.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 388a92d..e523672 100755 (executable)
@@ -2254,17 +2254,12 @@ class GeneralUtility
                 }
                 return false;
             }
-            $ctx = stream_context_create(array(
+            $ctx = stream_context_get_default(array(
                 'http' => array(
                     'header' => implode(CRLF, $requestHeaders)
                 )
             ));
-            $defaultCtx = stream_context_get_default();
-            if ($defaultCtx) {
-                $content = @file_get_contents($url);
-            } else {
-                $content = @file_get_contents($url, false, $ctx);
-            }
+            $content = @file_get_contents($url, false, $ctx);
             if ($content === false && isset($report)) {
                 $report['error'] = -1;
                 $report['message'] = 'Couldn\'t get URL: ' . (isset($http_response_header) ? implode(LF, $http_response_header) : $url);