Skip to content

Commit

Permalink
Improvement to bugfix for issue #104: json_encode(): Invalid UTF-8 se…
Browse files Browse the repository at this point in the history
…quence in argument in Log.php.

getLastResponse()->asString() would not gunzip the response first leading to binary data in the logs.
  • Loading branch information
Boy Baukema committed Nov 25, 2014
1 parent bbcccb0 commit d3fd3a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions library/EngineBlock/Rest/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public function get($args = array())
$this->_data = array();//Initializes for next Rest method.

if ($response->getStatus() !== 200) {
EngineBlock_ApplicationSingleton::getLog()->attach($response->asString(), 'Response');
EngineBlock_ApplicationSingleton::getLog()->attach(
$response->getHeadersAsString() . PHP_EOL . $response->getBody(),
'Response'
);

throw new EngineBlock_Exception(
'Response status !== 200', EngineBlock_Exception::CODE_WARNING
Expand All @@ -54,7 +57,10 @@ public function get($args = array())
return new Zend_Rest_Client_Result($response->getBody());
}
catch (Zend_Rest_Client_Result_Exception $e) {
EngineBlock_ApplicationSingleton::getLog()->attach($response->asString(), 'Response');
EngineBlock_ApplicationSingleton::getLog()->attach(
$response->getHeadersAsString() . PHP_EOL . $response->getBody(),
'Response'
);

throw new EngineBlock_Exception(
'Error parsing response', null, $e
Expand Down
7 changes: 5 additions & 2 deletions library/EngineBlock/VirtualOrganization/GroupValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ protected function _validateGroupMembership($subjectId, array $groups, $requireN
return $this->_validateGroupMembership($subjectId, $groups, true);
}
else {
EngineBlock_ApplicationSingleton::getLog()->attach($response->asString(), 'API Response');
EngineBlock_ApplicationSingleton::getLog()->attach(
$response->getHeadersAsString() . PHP_EOL . $response->getBody(),
'API Response'
);
throw new EngineBlock_Exception(
'Non-200 from API trying to get the group memberships'
);
Expand Down Expand Up @@ -121,4 +124,4 @@ protected function _ensureTrailingSlash($configuredUrl)
return $configuredUrl;
}

}
}
9 changes: 3 additions & 6 deletions library/Janus/Client/CacheProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ public function __call($name, $arguments)
);

if ($httpClient->getLastResponse()) {
$response = $httpClient->getLastResponse();
$application->getLogInstance()->attach(
$httpClient->getLastResponse()->getHeadersAsString(),
'HTTP Response headers'
);
$application->getLogInstance()->attach(
$httpClient->getLastResponse()->getBody(),
'HTTP Response body'
$response->getHeadersAsString() . PHP_EOL . $response->getBody(),
'HTTP Response'
);
}

Expand Down

0 comments on commit d3fd3a1

Please sign in to comment.