public function testPostAndFilesWithMultiCurl()
 {
     $get = array('get' => 'value');
     $post1 = array('c' => array('d&=@' => '@', 'e' => array('f' => array('1' => '2'), 'g' => array('4' => '3')), 'k' => $this->getFile1Path()));
     $post2 = array('post' => 'value');
     $files = array('file1' => $this->getFile1Path(), 'file2' => $this->getFile2Path());
     $body = file_get_contents($this->getFile1Path());
     $request1 = $this->spawnRequest(HttpMethod::post(), 'urlGet=super')->setGet($get)->setPost($post1);
     $request2 = $this->spawnRequest(HttpMethod::post())->setPost($post2)->setFiles($files);
     $request3 = $this->spawnRequest(HttpMethod::post())->setBody($body);
     $client = $this->spawnClient()->addRequest($request1)->addRequest($request2)->addRequest($request3);
     $client->multiSend();
     //check response 1st request
     $this->assertEquals($this->generateString(array('urlGet' => 'super') + $get, $post1, array(), UrlParamsUtils::toString($post1)), $client->getResponse($request1)->getBody());
     //check response 2nd request
     $filesExpectation = array('file1' => file_get_contents($this->getFile1Path()), 'file2' => file_get_contents($this->getFile2Path()));
     $this->assertEquals($this->generateString(array(), $post2, $filesExpectation, ''), $client->getResponse($request2)->getBody());
     //check response 3rd request
     $this->assertEquals($this->generateString(array(), array(), array(), $body), $client->getResponse($request3)->getBody());
 }
 public function testAnyDeepLvl()
 {
     $scope = array('foo' => array('foo' => array('foo' => '@bar')), 'bar' => array('@bar' => array('bar' => "foo[]я")), 'fo' => array(array('o', 'ba', 'r')));
     $this->assertEquals(array('foo[foo][foo]' => '@bar', 'bar[@bar][bar]' => 'foo[]я', 'fo[0][0]' => 'o', 'fo[0][1]' => 'ba', 'fo[0][2]' => 'r'), UrlParamsUtils::toParamsList($scope));
     $this->assertEquals('foo[foo][foo]=%40bar&bar[%40bar][bar]=foo%5B%5D%D1%8F&fo[0][0]=o&fo[0][1]=ba&fo[0][2]=r', UrlParamsUtils::toString($scope));
 }
 private function getPostFields(HttpRequest $request)
 {
     if ($request->hasBody()) {
         return $request->getBody();
     } else {
         if ($this->oldUrlConstructor) {
             return UrlParamsUtils::toStringOneDeepLvl($request->getPost());
         } else {
             $fileList = array_map(array($this, 'fileFilter'), UrlParamsUtils::toParamsList($request->getFiles()));
             if (empty($fileList)) {
                 return UrlParamsUtils::toString($request->getPost());
             } else {
                 $postList = UrlParamsUtils::toParamsList($request->getPost());
                 if (!is_null($atParam = $this->findAtParamInPost($postList))) {
                     throw new NetworkException('Security excepion: not allowed send post param ' . $atParam . ' which begins from @ in request which contains files');
                 }
                 return array_merge($postList, $fileList);
             }
         }
     }
 }