Skip to content

Commit

Permalink
Merge pull request #15 from codelathe/bugfix/line_break_to_split_head…
Browse files Browse the repository at this point in the history
…ers_and_body

Fixed the linebreak problem on debug mode.
  • Loading branch information
jefersonralmeida authored May 7, 2019
2 parents 407b599 + bdd15dc commit 8927ca9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fccloudapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 8927ca9

Please sign in to comment.