From 557313a840de116df5f0ad8823f9a3686d3c29a4 Mon Sep 17 00:00:00 2001 From: Mike Christopher Date: Thu, 5 Sep 2019 10:59:59 -0700 Subject: [PATCH] Updating HTTP header parsing --- Services/Zencoder.php | 4 ++-- Services/Zencoder/Http.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Services/Zencoder.php b/Services/Zencoder.php index ba8e209..8886970 100644 --- a/Services/Zencoder.php +++ b/Services/Zencoder.php @@ -231,10 +231,10 @@ private function _processResponse($response) if ( $status == 204 || (($status == 200 || $status == 201) && trim($body) == "")) { return TRUE; } - if (empty($headers['Content-Type'])) { + if (empty($headers['content-type'])) { throw new Services_Zencoder_Exception('Response header is missing Content-Type', $body); } - switch ($headers['Content-Type']) { + switch ($headers['content-type']) { case 'application/json': case 'application/json; charset=utf-8': return $this->_processJsonResponse($status, $headers, $body); diff --git a/Services/Zencoder/Http.php b/Services/Zencoder/Http.php index eed8c7d..0a27a95 100644 --- a/Services/Zencoder/Http.php +++ b/Services/Zencoder/Http.php @@ -115,7 +115,8 @@ public function __call($name, $args) { array_shift($header_lines); foreach ($header_lines as $line) { list($key, $value) = explode(":", $line, 2); - $headers[$key] = trim($value); + // Ensure headers are lowercase per https://tools.ietf.org/html/rfc2616#section-4.2 + $headers[strtolower($key)] = trim($value); } curl_close($curl); if (isset($buf) && is_resource($buf)) fclose($buf);