diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 4b1847e404a18acf3722a4cf806a9d6be9be3d20..e6c80c4b3e01e8aa00a301daf31245aa55c8f663 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -2183,19 +2183,24 @@ class SimpleSAML_Utilities { // Data and headers. if ($getHeaders) { - $headers = array(); - - foreach($http_response_header as $h) { - if(preg_match('@^HTTP/1\.[01]\s+\d{3}\s+@', $h)) { - $headers = array(); // reset - $headers[0] = $h; - continue; - } - $bits = explode(':', $h, 2); - if(count($bits) === 2) { - $headers[strtolower($bits[0])] = trim($bits[1]); + if (isset($http_response_header)) { + $headers = array(); + foreach($http_response_header as $h) { + if(preg_match('@^HTTP/1\.[01]\s+\d{3}\s+@', $h)) { + $headers = array(); // reset + $headers[0] = $h; + continue; + } + $bits = explode(':', $h, 2); + if(count($bits) === 2) { + $headers[strtolower($bits[0])] = trim($bits[1]); + } } + } else { + /* No HTTP headers - probably a different protocol, e.g. file. */ + $headers = NULL; } + return array($data, $headers); }