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 93c2f5e

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

File tree

3 files changed

+10
-1
lines changed
Filter options

3 files changed

+10
-1
lines changed

‎src/Symfony/Component/BrowserKit/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/CHANGELOG.md
+1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/HttpBrowser.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
+8Lines 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' => '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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.