Skip to content

Commit

Permalink
[HttpFoundation] fixed empty path when using Request::create() (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Oct 11, 2012
1 parent 593b845 commit 89f7b5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -286,7 +286,7 @@ public static function create($uri, $method = 'GET', $parameters = array(), $coo
}

if (!isset($components['path'])) {
$components['path'] = '';
$components['path'] = '/';
}

switch (strtoupper($method)) {
Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -127,6 +127,14 @@ public function testCreate()
$this->assertEquals('test.com', $request->getHttpHost());
$this->assertFalse($request->isSecure());

$request = Request::create('http://test.com?test=1');
$this->assertEquals('http://test.com/?test=1', $request->getUri());
$this->assertEquals('/', $request->getPathInfo());

This comment has been minimized.

Copy link
@Tobion

Tobion Oct 14, 2012

Member

This is not correct according to RFC 3986

the URI foo://info.example.com?fred has an empty path

$this->assertEquals('test=1', $request->getQueryString());
$this->assertEquals(80, $request->getPort());
$this->assertEquals('test.com', $request->getHttpHost());
$this->assertFalse($request->isSecure());

$request = Request::create('http://test.com:90/?test=1');
$this->assertEquals('http://test.com:90/?test=1', $request->getUri());
$this->assertEquals('/', $request->getPathInfo());
Expand Down

0 comments on commit 89f7b5e

Please sign in to comment.