Skip to content

Commit 3f0e7df

Browse files
committed
Merge pull request #44 from schneidermichal/master
Json decode only responses with json content type
2 parents 76ab3d5 + d44de17 commit 3f0e7df

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/Gitlab/HttpClient/Message/Response.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ class Response extends BaseResponse
1212
public function getContent()
1313
{
1414
$response = parent::getContent();
15-
$content = json_decode($response, true);
16-
17-
if (JSON_ERROR_NONE !== json_last_error()) {
15+
if ($this->getHeader("Content-Type") === "application/json") {
16+
$content = json_decode($response, true);
17+
18+
if (JSON_ERROR_NONE !== json_last_error()) {
19+
return $response;
20+
}
21+
22+
return $content;
23+
} else {
1824
return $response;
1925
}
20-
21-
return $content;
2226
}
2327
}

0 commit comments

Comments
 (0)