From ae318f83a09d21dfa859a9adea55abbfff592a91 Mon Sep 17 00:00:00 2001 From: John S Long Date: Sat, 12 Nov 2016 00:01:18 -0600 Subject: [PATCH] Disable CURLOPT_FAILONERROR to properly set body for non 2xx-responses. When making a request that returns in a status code other than 2xx, Curl would output the response to STDOUT instead of part of the response in the `curl_exec` call. This would cause the Response object returned from Client::makeRequest to contain nothing in the body. By telling curl not to fail on error, the body is left intact in the response from `curl_exec`, and the body is set as expected in the Response object returned from Client::makeRequest. --- lib/Client.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Client.php b/lib/Client.php index 1e77470..1e81d9c 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -144,6 +144,7 @@ public function makeRequest($method, $url, $body = null, $headers = null) curl_setopt_array($curl, array_merge([ CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => 1, + CURLOPT_FAILONERROR => false, CURLOPT_CUSTOMREQUEST => strtoupper($method), CURLOPT_SSL_VERIFYPEER => false, ], $this->curlOptions));