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 219d511

Browse filesBrowse files
feature #38622 [BrowserKit] Allowing body content from GET with a content-type (thiagomp)
This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [BrowserKit] Allowing body content from GET with a content-type | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #37609 | License | MIT | Doc PR | N/A This allows a GET request to sent a payload if it specifies a content-type in the HTTP header as per our conversation in the ticket. Commits ------- 93c2f5e [BrowserKit] Allowing body content from GET with a content-type
2 parents d07b951 + 93c2f5e commit 219d511
Copy full SHA for 219d511

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.