Skip to content

Commit 6a1666b

Browse files
driehuisAlexander Timmermann
authored and
Alexander Timmermann
committed
Be more precise in recognising three-part curl response (#102)
* 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.
1 parent b85d0c0 commit 6a1666b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/MessageBird/Common/HttpClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ public function performHttpRequest($method, $resourceName, $query = null, $body
219219

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

224225
curl_close($curl);
225226

0 commit comments

Comments
 (0)