8000 [BrowserKit] Allowing body content from GET with a content-type · symfony/symfony@93c2f5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 93c2f5e

Browse files
thiagompnicolas-grekas
authored andcommitted
[BrowserKit] Allowing body content from GET with a content-type
1 parent d07b951 commit 93c2f5e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/Symfony/Component/BrowserKit/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* Added `jsonRequest` method to `AbstractBrowser`
8+
* Allowed sending a body with GET requests when a content-type is defined
89

910
5.2.0
1011
-----

src/Symfony/Component/BrowserKit/HttpBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected function doRequest($request): Response
6161
*/
6262
private function getBodyAndExtraHeaders(Request $request, array $headers): array
6363
{
64-
if (\in_array($request->getMethod(), ['GET', 'HEAD'])) {
64+
if (\in_array($request->getMethod(), ['GET', 'HEAD']) && !isset($headers['content-type'])) {
6565
return ['', []];
6666
}
6767

src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ public function validContentTypes()
6363
['POST', 'http://example.com/', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'],
6464
['POST', 'http://example.com/', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
6565
];
66+
yield 'GET JSON' => [
67+
['GET', 'http://example.com/jsonrpc', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'],
68+
['GET', 'http://example.com/jsonrpc', ['headers' => $defaultHeaders + ['content-type' => ' 68A3 application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
69+
];
70+
yield 'HEAD JSON' => [
71+
['HEAD', 'http://example.com/jsonrpc', [], [], ['CONTENT_TYPE' => 'application/json'], '["content"]'],
72+
['HEAD', 'http://example.com/jsonrpc', ['headers' => $defaultHeaders + ['content-type' => 'application/json'], 'body' => '["content"]', 'max_redirects' => 0]],
73+
];
6674
}
6775

6876
public function testMultiPartRequestWithSingleFile()

0 commit comments

Comments
 (0)
0