Fix calling HTTPRequest::getReply() if the response is missing
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 12 Oct 2020 11:38:32 +0000 (13:38 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 12 Oct 2020 11:38:32 +0000 (13:38 +0200)
The only case where the response might be missing is if Guzzle fails to connect
to the remote server (ConnectException). Return default data that is consistent
with 5.2 in this case.

wcfsetup/install/files/lib/util/HTTPRequest.class.php

index e0eb6a22242b32df7684fbc3c56574cb7b5c2e6e..a3dd16ef89cebb7f828899bf5abf065a95593331 100644 (file)
@@ -261,6 +261,16 @@ final class HTTPRequest {
         * @return      array
         */
        public function getReply() {
+               if (!$this->response) {
+                       return [
+                               'statusCode' => 0,
+                               'headers' => [],
+                               'httpHeaders' => [],
+                               'body' => '',
+                               'url' => $this->url
+                       ];
+               }
+
                $headers = [];
                $legacyHeaders = [];