Skip to content

Commit

Permalink
[Http] Tolerating colons in response start-lines. Cleaning up parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jun 25, 2012
1 parent c7a2dd8 commit 7b44cc3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Message/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,7 @@ public function receiveResponseHeader($data)
$length = strlen($data);
$data = str_replace($normalize, '', $data);

if (strpos($data, ':') !== false) {

if (!$this->response) {
throw new RuntimeException('Received message-header before receiving start-line: ' . $data);
}

list($header, $value) = explode(':', $data, 2);
$this->response->addHeader(trim($header), trim($value));

} elseif (strlen($data) > 6) {
if (strpos($data, 'HTTP/') === 0) {

list($dummy, $code, $status) = explode(' ', $data, 3);

Expand All @@ -614,6 +605,11 @@ public function receiveResponseHeader($data)
'reason_phrase' => $status,
'previous_response' => $previousResponse
));

} elseif (strpos($data, ':') !== false) {

list($header, $value) = explode(':', $data, 2);
$this->response->addHeader(trim($header), trim($value));
}

return $length;
Expand Down

0 comments on commit 7b44cc3

Please sign in to comment.