Skip to content

Handle 'HTTP/1.1 100 Continue' header even if it's not the first header #22

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions Services/Zencoder/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down