Skip to content

Case-insensitive HTTP header parsing #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Services/Zencoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Services/Zencoder/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down