Skip to content

Commit

Permalink
Merge pull request #44 from schneidermichal/master
Browse files Browse the repository at this point in the history
Json decode only responses with json content type
  • Loading branch information
m4tthumphrey committed Jun 13, 2014
2 parents 76ab3d5 + d44de17 commit 3f0e7df
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/Gitlab/HttpClient/Message/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ class Response extends BaseResponse
public function getContent()
{
$response = parent::getContent();
$content = json_decode($response, true);

if (JSON_ERROR_NONE !== json_last_error()) {
if ($this->getHeader("Content-Type") === "application/json") {
$content = json_decode($response, true);

if (JSON_ERROR_NONE !== json_last_error()) {
return $response;
}

return $content;
} else {
return $response;
}

return $content;
}
}

0 comments on commit 3f0e7df

Please sign in to comment.