Skip to content

Commit

Permalink
Be more precise in recognising three-part curl response (#102)
Browse files Browse the repository at this point in the history
* Be more precise in recognising three-part curl response

* Split the recognition of a three part response from picking the correct bits out of the result array. Use strict checking for type safety.
  • Loading branch information
driehuis authored and Alexander Timmermann committed Oct 8, 2019
1 parent b85d0c0 commit 6a1666b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/MessageBird/Common/HttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ public function performHttpRequest($method, $resourceName, $query = null, $body

// Split the header and body
$parts = explode("\r\n\r\n", $response, 3);
list($responseHeader, $responseBody) = ($parts[0] === 'HTTP/1.1 100 Continue') ? array ($parts[1], $parts[2]) : array ($parts[0], $parts[1]);
$isThreePartResponse = (strpos($parts[0], "\n") === false && strpos($parts[0], 'HTTP/1.') === 0);
list($responseHeader, $responseBody) = $isThreePartResponse ? array ($parts[1], $parts[2]) : array ($parts[0], $parts[1]);

curl_close($curl);

Expand Down

0 comments on commit 6a1666b

Please sign in to comment.