diff --git a/fccloudapi.php b/fccloudapi.php index 9d34c21..dbc650d 100644 --- a/fccloudapi.php +++ b/fccloudapi.php @@ -2558,6 +2558,9 @@ protected function afterRequestDebug(string $method, string $url, string $postDa { if ($this->debug) { + // normalize the line breaks + $result = str_replace('\r\n', '\n', trim($result)); + // request $this->debugMessages['Request'] = "$method $url"; $body = []; @@ -2566,7 +2569,8 @@ protected function afterRequestDebug(string $method, string $url, string $postDa // request headers $rawRequest = curl_getinfo($this->curl_handle, CURLINFO_HEADER_OUT); - $lines = explode(PHP_EOL, trim($rawRequest)); + $rawRequest = str_replace('\r\n', '\n', trim($rawRequest)); + $lines = explode('\n', $rawRequest); array_shift($lines); // remove the first line and keep the headers $headers = []; foreach ($lines as $line) { @@ -2588,8 +2592,8 @@ protected function afterRequestDebug(string $method, string $url, string $postDa $this->debugMessages['Response Code'] = curl_getinfo($this->curl_handle, CURLINFO_HTTP_CODE); // Response Headers and body - [$rawHeaders, $body] = explode(PHP_EOL . PHP_EOL, $result); - $lines = explode(PHP_EOL, trim($rawHeaders)); + [$rawHeaders, $body] = explode('\n\n', $result); + $lines = explode('\n', trim($rawHeaders)); array_shift($lines); $headers = []; foreach ($lines as $line) {