[BUGFIX] Return http_code for HEAD requests in GeneralUtility::getUrl 94/51994/4
authorNicole Cordes <typo3@cordes.co>
Fri, 10 Mar 2017 00:07:49 +0000 (01:07 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 8 Jun 2017 14:02:23 +0000 (16:02 +0200)
As there is no content available for a HEAD request
GeneralUtility::getUrl currently returns an error message for HEAD
requests instead of proper http_code information. This patch ensures
all information are available.

Resolves: #80220
Releases: 7.6
Change-Id: I64108a16846a294f0bbee07289afcb79474833ea
Reviewed-on: https://review.typo3.org/51994
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 1cca06b..6f8c159 100644 (file)
@@ -2544,13 +2544,16 @@ class GeneralUtility
                     $report['content_type'] = $curlInfo['content_type'];
                     $report['error'] = CURLE_GOT_NOTHING;
                     $report['message'] = 'Expected "Location" header but got nothing.';
-                } elseif ($content === false) {
-                    $report['error'] = curl_errno($ch);
-                    $report['message'] = curl_error($ch);
-                } elseif ($includeHeader) {
+                } else {
+                    if ($content === false) {
+                        $report['error'] = curl_errno($ch);
+                        $report['message'] = curl_error($ch);
+                    }
                     // Set only for $includeHeader to work exactly like PHP variant
-                    $report['http_code'] = $curlInfo['http_code'];
-                    $report['content_type'] = $curlInfo['content_type'];
+                    if ($includeHeader) {
+                        $report['http_code'] = $curlInfo['http_code'];
+                        $report['content_type'] = $curlInfo['content_type'];
+                    }
                 }
             }
             curl_close($ch);