/**
  * @phutil-external-symbol class PhabricatorStartup
  */
 public function buildRequest()
 {
     $parser = new PhutilQueryStringParser();
     $data = array();
     // If the request has "multipart/form-data" content, we can't use
     // PhutilQueryStringParser to parse it, and the raw data supposedly is not
     // available anyway (according to the PHP documentation, "php://input" is
     // not available for "multipart/form-data" requests). However, it is
     // available at least some of the time (see T3673), so double check that
     // we aren't trying to parse data we won't be able to parse correctly by
     // examining the Content-Type header.
     $content_type = idx($_SERVER, 'CONTENT_TYPE');
     $is_form_data = preg_match('@^multipart/form-data@i', $content_type);
     $raw_input = PhabricatorStartup::getRawInput();
     if (strlen($raw_input) && !$is_form_data) {
         $data += $parser->parseQueryString($raw_input);
     } else {
         if ($_POST) {
             $data += $_POST;
         }
     }
     $data += $parser->parseQueryString(idx($_SERVER, 'QUERY_STRING', ''));
     $cookie_prefix = PhabricatorEnv::getEnvConfig('phabricator.cookie-prefix');
     $request = new AphrontRequest($this->getHost(), $this->getPath());
     $request->setRequestData($data);
     $request->setApplicationConfiguration($this);
     $request->setCookiePrefix($cookie_prefix);
     return $request;
 }
 public function testQueryStringParsing()
 {
     $map = array("" => array(), "foo=bar&foobar=barfoo" => array("foo" => "bar", "foobar" => "barfoo"), "a]b[]=1&a]=2&a[[]=3&a[b]b=4&[][a]=5" => array("a]b[]" => "1", "a]" => "2", "a[[]" => "3", "a[b]b" => "4", "[][a]" => "5"), "foo[][]=bar&bar[1][3]=foo" => array("foo" => array(0 => array(0 => "bar")), "bar" => array(1 => array(3 => "foo"))), "foo[][]=bar&a]b[]=1" => array("foo" => array(0 => array(0 => "bar")), "a]b[]" => "1"), "a&&b" => array("a" => "", "b" => ""), "a[b][]=foo&a[b][]=bar" => array("a" => array("b" => array(0 => "foo", 1 => "bar"))), 'a=1&a=2' => array('a' => '2'), 'a=1&a[]=2' => array('a' => array(0 => '2')), 'a=1&a[b]=2&a[]=3' => array('a' => array('b' => '2', 0 => '3')), 'a%20b=%20' => array('a b' => ' '), 'a.b=c' => array('a.b' => 'c'), 'a=b=c' => array('a' => 'b=c'));
     $parser = new PhutilQueryStringParser();
     foreach ($map as $query_string => $expected) {
         $this->assertEqual($expected, $parser->parseQueryString($query_string));
     }
 }
 public function testQueryStringParsing()
 {
     $map = array('' => array(), 'foo=bar&foobar=barfoo' => array('foo' => 'bar', 'foobar' => 'barfoo'), 'a]b[]=1&a]=2&a[[]=3&a[b]b=4&[][a]=5' => array('a]b[]' => '1', 'a]' => '2', 'a[[]' => '3', 'a[b]b' => '4', '[][a]' => '5'), 'foo[][]=bar&bar[1][3]=foo' => array('foo' => array(0 => array(0 => 'bar')), 'bar' => array(1 => array(3 => 'foo'))), 'foo[][]=bar&a]b[]=1' => array('foo' => array(0 => array(0 => 'bar')), 'a]b[]' => '1'), 'a&&b' => array('a' => '', 'b' => ''), 'a[b][]=foo&a[b][]=bar' => array('a' => array('b' => array(0 => 'foo', 1 => 'bar'))), 'a=1&a=2' => array('a' => '2'), 'a=1&a[]=2' => array('a' => array(0 => '2')), 'a=1&a[b]=2&a[]=3' => array('a' => array('b' => '2', 0 => '3')), 'a%20b=%20' => array('a b' => ' '), 'a.b=c' => array('a.b' => 'c'), 'a=b=c' => array('a' => 'b=c'));
     $parser = new PhutilQueryStringParser();
     foreach ($map as $query_string => $expected) {
         $this->assertEqual($expected, $parser->parseQueryString($query_string));
     }
 }