Skip to content

Commit 96e6eca

Browse files
authored
Merge pull request #96 from innamhunzai/master
Separate headers and response body using CURLINFO_HEADER_SIZE flag
2 parents 5e20d6d + 0b859ea commit 96e6eca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

PSWebServiceLibrary.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ protected function executeRequest($url, $curl_params = array())
192192
curl_setopt_array($session, $curl_options);
193193
$response = curl_exec($session);
194194

195-
$index = strpos($response, "\r\n\r\n");
196-
if ($index === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
195+
$headerSize = curl_getinfo($session, CURLINFO_HEADER_SIZE);
196+
if ($headerSize === false && $curl_params[CURLOPT_CUSTOMREQUEST] != 'HEAD') {
197197
throw new PrestaShopWebserviceException('Bad HTTP response ' . $response . curl_error($session));
198198
}
199199

200-
$header = substr($response, 0, $index);
201-
$body = substr($response, $index + 4);
200+
$header = substr($response, 0, $headerSize);
201+
$body = substr($response, $headerSize);
202202

203203
$headerArrayTmp = explode("\n", $header);
204204

0 commit comments

Comments
 (0)