[BUGFIX] Treat empty responses as error in GeneralUtility::getUrl 39/56039/5
authorFelix Buenemann <felix.buenemann@gmail.com>
Wed, 7 Mar 2018 20:51:52 +0000 (21:51 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 8 Mar 2018 01:43:06 +0000 (02:43 +0100)
This fixes a negation bug introduced when the GeneralUtility::getUrl
code was converted to use GuzzleHttp instead of cURL.

Also updated ErrorController test doubles that where asserting the
wrong behavior.

Resolves: #84167
Releases: master, 8.7
Change-Id: I9b8982dc34f8a4ac22769beb7f837f090ce73f23
Reviewed-on: https://review.typo3.org/56039
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Tests/Unit/Controller/ErrorControllerTest.php

index 72c59e8..ebeb1b1 100644 (file)
@@ -1849,7 +1849,7 @@ class GeneralUtility
                     $report['content_type'] = $response->getHeader('Content-Type');
                     $report['error'] = $response->getStatusCode();
                     $report['message'] = $response->getReasonPhrase();
-                } elseif (!empty($content)) {
+                } elseif (empty($content)) {
                     $report['error'] = $response->getStatusCode();
                     $report['message'] = $response->getReasonPhrase();
                 } elseif ($includeHeader) {
index 7ae93cd..7c05fca 100644 (file)
@@ -501,7 +501,7 @@ X-TYPO3-Additional-Header: Banana Stand';
         $prefixPageResponseProphecy->getHeaders()->willReturn([]);
         $prefixPageResponseProphecy->getBody()->willReturn($streamProphecy);
         $prefixPageResponseProphecy->getStatusCode()->willReturn(200);
-        $prefixPageResponseProphecy->getReasonPhrase()->willReturn('OK');
+        $prefixPageResponseProphecy->getHeader('Content-Type')->willReturn(['text/html; charset=utf-8']);
         $requestFactoryProphecy = $this->prophesize(RequestFactory::class);
         $requestFactoryProphecy->request(Argument::cetera())->willReturn($prefixPageResponseProphecy->reveal());
         GeneralUtility::addInstance(RequestFactory::class, $requestFactoryProphecy->reveal());