diff --git a/src/Curl/Curl.php b/src/Curl/Curl.php index 76c1e93..1af722d 100644 --- a/src/Curl/Curl.php +++ b/src/Curl/Curl.php @@ -433,7 +433,7 @@ class Curl $ch->call($this->complete_function, $ch); - return $ch->error_code; + return $ch->response; } private function call($function) diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index d7b5c2f..a54e687 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -305,6 +305,15 @@ class CurlTest extends PHPUnit_Framework_TestCase )) === 'myreferrer'); } + public function testResponseBody() + { + foreach (array('GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS') as $request_method) { + $curl = new Curl(); + $curl->setHeader('X-DEBUG-TEST', 'response_body'); + $this->assertTrue($curl->$request_method(Test::TEST_URL) === 'OK'); + } + } + public function testCookies() { $test = new Test(); diff --git a/tests/PHPCurlClass/server.php b/tests/PHPCurlClass/server.php index 921dc65..8e78995 100644 --- a/tests/PHPCurlClass/server.php +++ b/tests/PHPCurlClass/server.php @@ -79,6 +79,9 @@ if ($test == 'http_basic_auth') { header('Content-Type: application/json'); header('ETag: ' . md5('worldpeace')); exit; +} elseif ($test === 'response_body') { + echo 'OK'; + exit; } elseif ($test === 'json_response') { $key = $_POST['key']; $value = $_POST['value'];