Skip to content

Navigation Menu

Sign in
Appearance settings

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 33a5a3e

Browse filesBrowse files
committed
minor #59100 [HttpClient] Test POST to GET redirects (KurtThiemann)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [HttpClient] Test POST to GET redirects | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | idk | New feature? | no | Deprecations? | no | Issues | - | License | MIT In a discussion in #59062 after that pull request was already merged, it was suggested that the changes of that pull request might break POST-to-GET redirects. While it turned out that they do not because of how Symfony handles redirects, but I thought it might be a good idea to just test this. Commits ------- a96cfa4 [HttpClient] Test POST to GET redirects
2 parents 3fc8d0f + a96cfa4 commit 33a5a3e
Copy full SHA for 33a5a3e

File tree

2 files changed

+32
-0
lines changed
Filter options

2 files changed

+32
-0
lines changed

‎src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,4 +673,26 @@ public function testHeadRequestWithClosureBody()
673673
$this->assertIsArray($vars);
674674
$this->assertSame('HEAD', $vars['REQUEST_METHOD']);
675675
}
676+
677+
/**
678+
* @testWith [301]
679+
* [302]
680+
* [303]
681+
*/
682+
public function testPostToGetRedirect(int $status)
683+
{
684+
$p = TestHttpServer::start(8067);
685+
686+
try {
687+
$client = $this->getHttpClient(__FUNCTION__);
688+
689+
$response = $client->request('POST', 'http://localhost:8057/custom?status=' . $status . '&headers[]=Location%3A%20%2F');
690+
$body = $response->toArray();
691+
} finally {
692+
$p->stop();
693+
}
694+
695+
$this->assertSame('GET', $body['REQUEST_METHOD']);
696+
$this->assertSame('/', $body['REQUEST_URI']);
697+
}
676698
}

‎src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php

Copy file name to clipboardExpand all lines: src/Symfony/Contracts/HttpClient/Test/Fixtures/web/index.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,16 @@
199199
]);
200200

201201
exit;
202+
203+
case '/custom':
204+
if (isset($_GET['status'])) {
205+
http_response_code((int) $_GET['status']);
206+
}
207+
if (isset($_GET['headers']) && is_array($_GET['headers'])) {
208+
foreach ($_GET['headers'] as $header) {
209+
header($header);
210+
}
211+
}
202212
}
203213

204214
header('Content-Type: application/json', true);

0 commit comments

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