[BUGFIX] Reallow custom request context in getUrl 68/46668/2
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:14:47 +0000 (13:14 +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/46668
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 278554c..45948b1 100755 (executable)
@@ -2592,17 +2592,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);