From 2369c9a0bca4780ec929a8f32d47ae0979263a32 Mon Sep 17 00:00:00 2001 From: Craig Anderson Date: Thu, 15 Jan 2015 15:12:00 +1100 Subject: [PATCH] Handle 'HTTP/1.1 100 Continue' header even if it's not the first header --- Services/Zencoder/Http.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Services/Zencoder/Http.php b/Services/Zencoder/Http.php index eed8c7d..da44aeb 100644 --- a/Services/Zencoder/Http.php +++ b/Services/Zencoder/Http.php @@ -100,10 +100,17 @@ public function __call($name, $args) { if ($curl = curl_init()) { if (curl_setopt_array($curl, $opts)) { if ($response = curl_exec($curl)) { - $parts = explode("\r\n\r\n", $response, 3); - list($head, $body) = ($parts[0] == 'HTTP/1.1 100 Continue') - ? array($parts[1], $parts[2]) - : array($parts[0], $parts[1]); + list($head, $body) = explode("\r\n\r\n", $response, 2); + $parts = explode("\r\n\r\n", $response); + foreach ($parts as $i => $part) { + if ($i >= count($parts) - 2) { + break; // don't bother continuing if there's no head or body candidate to come + } + if ($part == 'HTTP/1.1 100 Continue') { + $head = $parts[$i + 1]; + $body = implode("\r\n\r\n", array_slice($parts, $i + 2)); + } + } $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($this->debug) { error_log(