[HttpFoundation] fixed Request::create() when passing arguments as an array (closes #3314)
This commit is contained in:
parent
a899548d79
commit
5efbd9f50e
@ -293,28 +293,25 @@ class Request
|
||||
default:
|
||||
$request = array();
|
||||
$query = $parameters;
|
||||
if (false !== $pos = strpos($uri, '?')) {
|
||||
$qs = substr($uri, $pos + 1);
|
||||
parse_str($qs, $params);
|
||||
|
||||
$query = array_merge($params, $query);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$queryString = isset($components['query']) ? html_entity_decode($components['query']) : '';
|
||||
parse_str($queryString, $qs);
|
||||
if (is_array($qs)) {
|
||||
$query = array_replace($qs, $query);
|
||||
if (isset($components['query'])) {
|
||||
$queryString = html_entity_decode($components['query']);
|
||||
parse_str($queryString, $qs);
|
||||
if (is_array($qs)) {
|
||||
$query = array_replace($qs, $query);
|
||||
}
|
||||
}
|
||||
$queryString = http_build_query($query);
|
||||
|
||||
$uri = $components['path'].($queryString ? '?'.$queryString : '');
|
||||
|
||||
$server = array_replace($defaults, $server, array(
|
||||
'REQUEST_METHOD' => strtoupper($method),
|
||||
'PATH_INFO' => '',
|
||||
'REQUEST_URI' => $uri,
|
||||
'QUERY_STRING' => $queryString,
|
||||
'REQUEST_METHOD' => strtoupper($method),
|
||||
'PATH_INFO' => '',
|
||||
'REQUEST_URI' => $uri,
|
||||
'QUERY_STRING' => $queryString,
|
||||
));
|
||||
|
||||
return new static($query, $request, array(), $cookies, $files, $server, $content);
|
||||
|
@ -64,6 +64,22 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('test.com', $request->getHttpHost());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
$request = Request::create('http://test.com/foo', 'GET', array('bar' => 'baz'));
|
||||
$this->assertEquals('http://test.com/foo?bar=baz', $request->getUri());
|
||||
$this->assertEquals('/foo', $request->getPathInfo());
|
||||
$this->assertEquals('bar=baz', $request->getQueryString());
|
||||
$this->assertEquals(80, $request->getPort());
|
||||
$this->assertEquals('test.com', $request->getHttpHost());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
$request = Request::create('http://test.com/foo?bar=foo', 'GET', array('bar' => 'baz'));
|
||||
$this->assertEquals('http://test.com/foo?bar=baz', $request->getUri());
|
||||
$this->assertEquals('/foo', $request->getPathInfo());
|
||||
$this->assertEquals('bar=baz', $request->getQueryString());
|
||||
$this->assertEquals(80, $request->getPort());
|
||||
$this->assertEquals('test.com', $request->getHttpHost());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
$request = Request::create('https://test.com/foo?bar=baz');
|
||||
$this->assertEquals('https://test.com/foo?bar=baz', $request->getUri());
|
||||
$this->assertEquals('/foo', $request->getPathInfo());
|
||||
|
Reference in New Issue
Block a user