merged branch fabpot/request-create-fix (PR #7098)
This PR was merged into the 2.2 branch. Commits -------738de9a
[HttpKernel] added a unit for the previous commit (closes #7025)d0e4b76
[HttpFoundation] fixed, overwritten CONTENT_TYPE Discussion ---------- Fixed content type when passed as a server value | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7025 | License | MIT | Doc PR | n/a --------------------------------------------------------------------------- by stof at 2013-02-17T14:51:35Z 👍
This commit is contained in:
commit
fc73d9f049
@ -325,7 +325,9 @@ class Request
|
|||||||
case 'POST':
|
case 'POST':
|
||||||
case 'PUT':
|
case 'PUT':
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
if (!isset($server['CONTENT_TYPE'])) {
|
||||||
|
$server['CONTENT_TYPE'] = 'application/x-www-form-urlencoded';
|
||||||
|
}
|
||||||
case 'PATCH':
|
case 'PATCH':
|
||||||
$request = $parameters;
|
$request = $parameters;
|
||||||
$query = array();
|
$query = array();
|
||||||
|
@ -228,13 +228,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testCreateCheckPrecedence()
|
public function testCreateCheckPrecedence()
|
||||||
{
|
{
|
||||||
// server is used by default
|
// server is used by default
|
||||||
$request = Request::create('/', 'GET', array(), array(), array(), array(
|
$request = Request::create('/', 'DELETE', array(), array(), array(), array(
|
||||||
'HTTP_HOST' => 'example.com',
|
'HTTP_HOST' => 'example.com',
|
||||||
'HTTPS' => 'on',
|
'HTTPS' => 'on',
|
||||||
'SERVER_PORT' => 443,
|
'SERVER_PORT' => 443,
|
||||||
'PHP_AUTH_USER' => 'fabien',
|
'PHP_AUTH_USER' => 'fabien',
|
||||||
'PHP_AUTH_PW' => 'pa$$',
|
'PHP_AUTH_PW' => 'pa$$',
|
||||||
'QUERY_STRING' => 'foo=bar',
|
'QUERY_STRING' => 'foo=bar',
|
||||||
|
'CONTENT_TYPE' => 'application/json',
|
||||||
));
|
));
|
||||||
$this->assertEquals('example.com', $request->getHost());
|
$this->assertEquals('example.com', $request->getHost());
|
||||||
$this->assertEquals(443, $request->getPort());
|
$this->assertEquals(443, $request->getPort());
|
||||||
@ -242,6 +243,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('fabien', $request->getUser());
|
$this->assertEquals('fabien', $request->getUser());
|
||||||
$this->assertEquals('pa$$', $request->getPassword());
|
$this->assertEquals('pa$$', $request->getPassword());
|
||||||
$this->assertEquals('', $request->getQueryString());
|
$this->assertEquals('', $request->getQueryString());
|
||||||
|
$this->assertEquals('application/json', $request->headers->get('CONTENT_TYPE'));
|
||||||
|
|
||||||
// URI has precedence over server
|
// URI has precedence over server
|
||||||
$request = Request::create('http://thomas:pokemon@example.net:8080/?foo=bar', 'GET', array(), array(), array(), array(
|
$request = Request::create('http://thomas:pokemon@example.net:8080/?foo=bar', 'GET', array(), array(), array(), array(
|
||||||
|
Reference in New Issue
Block a user