[HttpFoundation] tried to keep the original Request URI as much as possible to avoid different behavior between ::createFromGlobals() and ::create()
This commit is contained in:
parent
6ec2cbaa6c
commit
4f5b8f04f1
@ -348,11 +348,20 @@ class Request
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$queryString = '';
|
||||||
if (isset($components['query'])) {
|
if (isset($components['query'])) {
|
||||||
parse_str(html_entity_decode($components['query']), $qs);
|
parse_str(html_entity_decode($components['query']), $qs);
|
||||||
$query = array_replace($qs, $query);
|
|
||||||
|
if ($query) {
|
||||||
|
$query = array_replace($qs, $query);
|
||||||
|
$queryString = http_build_query($query, '', '&');
|
||||||
|
} else {
|
||||||
|
$query = $qs;
|
||||||
|
$queryString = $components['query'];
|
||||||
|
}
|
||||||
|
} elseif ($query) {
|
||||||
|
$queryString = http_build_query($query, '', '&');
|
||||||
}
|
}
|
||||||
$queryString = http_build_query($query, '', '&');
|
|
||||||
|
|
||||||
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
|
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
|
||||||
$server['QUERY_STRING'] = $queryString;
|
$server['QUERY_STRING'] = $queryString;
|
||||||
|
@ -220,6 +220,10 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('testnopass', $request->getUser());
|
$this->assertEquals('testnopass', $request->getUser());
|
||||||
$this->assertNull($request->getPassword());
|
$this->assertNull($request->getPassword());
|
||||||
$this->assertFalse($request->isSecure());
|
$this->assertFalse($request->isSecure());
|
||||||
|
|
||||||
|
$request = Request::create('http://test.com/?foo');
|
||||||
|
$this->assertEquals('/?foo', $request->getRequestUri());
|
||||||
|
$this->assertEquals(array('foo' => ''), $request->query->all());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user