Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #655 from bhoehl/master
Browse files Browse the repository at this point in the history
bugfix: UTF8 encoding in result response from sandbox, corrupts json response
  • Loading branch information
Jay authored Sep 26, 2016
2 parents 4707368 + 667d574 commit 8757cdb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/PayPal/Core/PayPalHttpConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,15 @@ public function execute($data)
// Get Request and Response Headers
$requestHeaders = curl_getinfo($ch, CURLINFO_HEADER_OUT);
//Using alternative solution to CURLINFO_HEADER_SIZE as it throws invalid number when called using PROXY.
$responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = substr($result, 0, $responseHeaderSize);
$result = substr($result, $responseHeaderSize);
if (function_exists('mb_strlen')) {
$responseHeaderSize = mb_strlen($result, '8bit') - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = mb_substr($result, 0, $responseHeaderSize, '8bit');
$result = mb_substr($result, $responseHeaderSize, null, '8bit');
} else {
$responseHeaderSize = strlen($result) - curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
$responseHeaders = substr($result, 0, $responseHeaderSize);
$result = substr($result, $responseHeaderSize);
}

$this->logger->debug("Request Headers \t: " . str_replace("\r\n", ", ", $requestHeaders));
$this->logger->debug(($data && $data != '' ? "Request Data\t\t: " . $data : "No Request Payload") . "\n" . str_repeat('-', 128) . "\n");
Expand Down

0 comments on commit 8757cdb

Please sign in to comment.