diff --git a/lib/Unirest/Unirest.php b/lib/Unirest/Unirest.php index 86beea3..f190b25 100644 --- a/lib/Unirest/Unirest.php +++ b/lib/Unirest/Unirest.php @@ -234,7 +234,7 @@ class Unirest $pairs = explode("&", $querystring); $vars = array(); foreach ($pairs as $pair) { - $nv = explode("=", $pair); + $nv = explode("=", $pair, 2); $name = $nv[0]; $value = $nv[1]; $vars[$name] = $value; diff --git a/test/Unirest/UnirestTest.php b/test/Unirest/UnirestTest.php index 8dbd2f7..fc72659 100644 --- a/test/Unirest/UnirestTest.php +++ b/test/Unirest/UnirestTest.php @@ -87,6 +87,34 @@ class UnirestTest extends UnitTestCase $this->assertEqual("thefosk", $form->nick); } + public function testPostWithEqualSign() + { + $response = Unirest::post("http://httpbin.org/post", array( + "Accept" => "application/json" + ), array( + "name" => "Mark=Hello" + )); + + $this->assertEqual(200, $response->code); + + $form = $response->body->form; + $this->assertEqual("Mark=Hello", $form->name); + } + + public function testGetWithEqualSign() + { + $response = Unirest::get("http://httpbin.org/get", array( + "Accept" => "application/json" + ), array( + "name" => "Mark=Hello" + )); + + $this->assertEqual(200, $response->code); + + $args = $response->body->args; + $this->assertEqual("Mark=Hello", $args->name); + } + public function testPostArray() { $response = Unirest::post("http://httpbin.org/post", array(