diff --git a/Curl.class.php b/Curl.class.php index 096e8ff..f2c376e 100644 --- a/Curl.class.php +++ b/Curl.class.php @@ -106,6 +106,10 @@ class Curl { private function http_build_multi_query($data, $key=NULL) { $query = array(); + if (empty($data)) { + return $key . '='; + } + $is_array_assoc = is_array_assoc($data); foreach ($data as $k => $value) { diff --git a/tests/run.php b/tests/run.php index 26764e0..7f4d170 100644 --- a/tests/run.php +++ b/tests/run.php @@ -250,5 +250,30 @@ class CurlTest extends PHPUnit_Framework_TestCase { ), )); $this->assertTrue($test->curl->response === 'foo=bar&baz='); + + $test = new Test(); + $test->server('post', 'POST', array( + 'foo' => 'bar', + 'baz' => array( + 'qux' => array( + ), + ), + )); + $this->assertTrue(urldecode($test->curl->response) === + 'foo=bar&baz[qux]=' + ); + + $test = new Test(); + $test->server('post', 'POST', array( + 'foo' => 'bar', + 'baz' => array( + 'qux' => array( + ), + 'wibble' => 'wobble', + ), + )); + $this->assertTrue(urldecode($test->curl->response) === + 'foo=bar&baz[qux]=&baz[wibble]=wobble' + ); } }