Check if $body is traversable before recursively sanitizing (allows for raw JSON body)

Add testRawPost()
This commit is contained in:
Sam Sullivan
2014-01-13 23:21:04 -06:00
parent f5fee2dc46
commit 646e24aefe
2 changed files with 20 additions and 3 deletions

View File

@@ -90,6 +90,19 @@ class UnirestTest extends UnitTestCase
$this->assertEqual("thefosk", $form->nick);
}
public function testRawPost()
{
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
json_encode(array(
"author" => "Sam Sullivan"
)));
$this->assertEqual(200, $response->code);
$json = $response->body->json;
$this->assertEqual("Sam Sullivan", $json->author);
}
public function testUpload() {
$response = Unirest::post("http://httpbin.org/post", array( "Accept" => "application/json" ),
array(