Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94fcfa5

Browse filesBrowse files
mtibbenfabpot
authored andcommitted
Fix the request target in PSR7 Request
1 parent 147a238 commit 94fcfa5
Copy full SHA for 94fcfa5

File tree

2 files changed

+7
-1
lines changed
Filter options

2 files changed

+7
-1
lines changed

‎Factory/DiactorosFactory.php

Copy file name to clipboardExpand all lines: Factory/DiactorosFactory.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function createRequest(Request $symfonyRequest)
5555
$request = new ServerRequest(
5656
$server,
5757
DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all())),
58-
$symfonyRequest->getUri(),
58+
$symfonyRequest->getSchemeAndHttpHost().$symfonyRequest->getRequestUri(),
5959
$symfonyRequest->getMethod(),
6060
$body,
6161
$headers
@@ -65,6 +65,7 @@ public function createRequest(Request $symfonyRequest)
6565
->withCookieParams($symfonyRequest->cookies->all())
6666
->withQueryParams($symfonyRequest->query->all())
6767
->withParsedBody($symfonyRequest->request->all())
68+
->withRequestTarget($symfonyRequest->getRequestUri())
6869
;
6970

7071
foreach ($symfonyRequest->attributes->all() as $key => $value) {

‎Tests/Factory/DiactorosFactoryTest.php

Copy file name to clipboardExpand all lines: Tests/Factory/DiactorosFactoryTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function testCreateRequest()
6969
'REQUEST_METHOD' => 'POST',
7070
'HTTP_HOST' => 'dunglas.fr',
7171
'HTTP_X_SYMFONY' => '2.8',
72+
'REQUEST_URI' => '/testCreateRequest?foo=1&bar[baz]=42',
73+
'QUERY_STRING' => 'foo=1&bar[baz]=42',
7274
),
7375
'Content'
7476
);
@@ -81,6 +83,9 @@ public function testCreateRequest()
8183
$this->assertEquals('1', $queryParams['foo']);
8284
$this->assertEquals('42', $queryParams['bar']['baz']);
8385

86+
$requestTarget = $psrRequest->getRequestTarget();
87+
$this->assertEquals('/testCreateRequest?foo=1&bar[baz]=42', $requestTarget);
88+
8489
$parsedBody = $psrRequest->getParsedBody();
8590
$this->assertEquals('Kévin Dunglas', $parsedBody['twitter']['@dunglas']);
8691
$this->assertEquals('Les-Tilleuls.coop', $parsedBody['twitter']['@coopTilleuls']);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.