Skip to content

Commit

Permalink
Merge pull request #97 from matomo-org/double-newline-bugfix
Browse files Browse the repository at this point in the history
Fix for double newline issue when a redirect is used
  • Loading branch information
tsteur authored Nov 14, 2021
2 parents a780944 + 1cc8a26 commit 1afff79
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions MatomoTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -1708,15 +1708,21 @@ protected function sendRequest($url, $method = 'GET', $data = null, $force = fal
ob_start();
$response = @curl_exec($ch);
ob_end_clean();

$header = '';
$content = '';

if ($response === false) {
throw new \RuntimeException(curl_error($ch));
}

if (!empty($response)) {
list($header, $content) = explode("\r\n\r\n", $response, $limitCount = 2);
// extract header
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $headerSize);

// extract content
$content = substr($response, $headerSize);
}

$this->parseIncomingCookies(explode("\r\n", $header));
Expand Down

0 comments on commit 1afff79

Please sign in to comment.