Skip to content

Commit 99aa470

Browse files
author
Nathan Sutton
authored
Merge pull request #34 from mchristopher/master
Case-insensitive HTTP header parsing, courtesy of Michael Christopher
2 parents a945431 + 557313a commit 99aa470

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Services/Zencoder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ private function _processResponse($response)
231231
if ( $status == 204 || (($status == 200 || $status == 201) && trim($body) == "")) {
232232
return TRUE;
233233
}
234-
if (empty($headers['Content-Type'])) {
234+
if (empty($headers['content-type'])) {
235235
throw new Services_Zencoder_Exception('Response header is missing Content-Type', $body);
236236
}
237-
switch ($headers['Content-Type']) {
237+
switch ($headers['content-type']) {
238238
case 'application/json':
239239
case 'application/json; charset=utf-8':
240240
return $this->_processJsonResponse($status, $headers, $body);

Services/Zencoder/Http.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ public function __call($name, $args) {
115115
array_shift($header_lines);
116116
foreach ($header_lines as $line) {
117117
list($key, $value) = explode(":", $line, 2);
118-
$headers[$key] = trim($value);
118+
// Ensure headers are lowercase per https://tools.ietf.org/html/rfc2616#section-4.2
119+
$headers[strtolower($key)] = trim($value);
119120
}
120121
curl_close($curl);
121122
if (isset($buf) && is_resource($buf)) fclose($buf);

0 commit comments

Comments
 (0)