MDL-47198 filelib: fix curl handling headers with no value
authorDavo Smith <git@davosmith.co.uk>
Thu, 16 Oct 2014 11:52:31 +0000 (12:52 +0100)
committerDavo Smith <git@davosmith.co.uk>
Fri, 16 Dec 2016 13:19:48 +0000 (13:19 +0000)
lib/filelib.php

index 9b1e02c..b568436 100644 (file)
@@ -3056,8 +3056,9 @@ class curl {
                 $this->responsefinished = false;
                 $this->response = array();
             }
-            list($key, $value) = explode(" ", rtrim($header, "\r\n"), 2);
-            $key = rtrim($key, ':');
+            $parts = explode(" ", rtrim($header, "\r\n"), 2);
+            $key = rtrim($parts[0], ':');
+            $value = isset($parts[1]) ? $parts[1] : null;
             if (!empty($this->response[$key])) {
                 if (is_array($this->response[$key])) {
                     $this->response[$key][] = $value;