Skip to content

Commit

Permalink
Merge branch 'hotfix/zendframework#7137-zendframework#7005-phpenviron…
Browse files Browse the repository at this point in the history
…ment-request-ignores-query-string-fix'

Close zendframework#7137
Close zendframework#7005
  • Loading branch information
Ocramius committed Jan 19, 2015
2 parents 4513cc4 + e8cc3bf commit 7e704a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions library/Zend/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public static function fromString($string)
$request->setMethod($matches['method']);
$request->setUri($matches['uri']);

$parsedUri = parse_url($matches['uri']);
if (array_key_exists('query', $parsedUri)) {
$parsedQuery = array();
parse_str($parsedUri['query'], $parsedQuery);
$request->setQuery(new Parameters($parsedQuery));
}

if (isset($matches['version'])) {
$request->setVersion($matches['version']);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/ZendTest/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase
{
public function testRequestFromStringFactoryCreatesValidRequest()
{
$string = "GET /foo HTTP/1.1\r\n\r\nSome Content";
$string = "GET /foo?myparam=myvalue HTTP/1.1\r\n\r\nSome Content";
$request = Request::fromString($string);

$this->assertEquals(Request::METHOD_GET, $request->getMethod());
$this->assertEquals('/foo', $request->getUri());
$this->assertEquals('/foo?myparam=myvalue', $request->getUri());
$this->assertEquals('myvalue', $request->getQuery()->get('myparam'));
$this->assertEquals(Request::VERSION_11, $request->getVersion());
$this->assertEquals('Some Content', $request->getContent());
}
Expand Down

0 comments on commit 7e704a7

Please sign in to comment.