mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-15 12:56:40 +00:00
Fix #53: Return response body when calling HTTP request methods
This commit is contained in:
+1
-1
@@ -433,7 +433,7 @@ class Curl
|
||||
|
||||
$ch->call($this->complete_function, $ch);
|
||||
|
||||
return $ch->error_code;
|
||||
return $ch->response;
|
||||
}
|
||||
|
||||
private function call($function)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user