Merge pull request #558 from zachborboa/master

Add tests for content-length with DELETE requests
This commit is contained in:
Zach Borboa
2018-11-29 23:15:55 -08:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
+3 -1
View File
@@ -265,7 +265,9 @@ class Curl
$this->setUrl($url, $query_parameters);
$this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE');
$this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data));
if (!empty($data)) {
$this->setOpt(CURLOPT_POSTFIELDS, $this->buildPostData($data));
}
return $this->exec();
}
+16
View File
@@ -622,6 +622,22 @@ class CurlTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('{"get":{"foo":"bar"},"delete":{"wibble":"wubble"}}', $test->curl->rawResponse);
}
public function testDeleteContentLengthSetWithBody()
{
$request_body = 'a=1&b=2&c=3';
$test = new Test();
$test->server('request_method', 'DELETE', array(), $request_body);
$this->assertEquals(strlen($request_body), $test->curl->requestHeaders['content-length']);
}
public function testDeleteContentLengthUnsetWithoutBody()
{
$request_body = array();
$test = new Test();
$test->server('request_method', 'DELETE', array(), $request_body);
$this->assertFalse(isset($test->curl->requestHeaders['content-length']));
}
public function testHeadRequestMethod()
{
$test = new Test();