8000 Fix HttpClientTrait::jsonEncode flags usage · symfony/symfony@bb0ddf1 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb0ddf1

Browse files
committed
Fix HttpClientTrait::jsonEncode flags usage
1 parent f0247e0 commit bb0ddf1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function getCurlCommand(array $trace): ?string
194194
$dataArg = [];
195195

196196
if ($json = $trace['options']['json'] ?? null) {
197-
$dataArg[] = '--data '.escapeshellarg(json_encode($json, \JSON_PRETTY_PRINT));
197+
$dataArg[] = '--data '.escapeshellarg(self::jsonEncode($json));
198198
} elseif ($body = $trace['options']['body'] ?? null) {
199199
if (\is_string($body)) {
200200
try {

src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ public function __toString(): string
307307
'json' => [
308308
'foo' => [
309309
'bar' => 'baz',
310+
'qux' => [1.10, 1.0],
311+
'fred' => ['<foo>',"'bar'",'"baz"','&blong&'],
310312
],
311313
],
312314
],
@@ -317,14 +319,10 @@ public function __toString(): string
317319
--url %1$shttp://localhost:8057/json%1$s \\
318320
--header %1$sContent-Type: application/json%1$s \\
319321
--header %1$sAccept: */*%1$s \\
320-
--header %1$sContent-Length: 21%1$s \\
322+
--header %1$sContent-Length: 120%1$s \\
321323
--header %1$sAccept-Encoding: gzip%1$s \\
322324
--header %1$sUser-Agent: Symfony HttpClient/Native%1$s \\
323-
--data %1$s{
324-
"foo": {
325-
"bar": "baz"
326-
}
327-
}%1$s',
325+
--data %1$s{"foo":{"bar":"baz","qux":[1.1,1.0],"fred":["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]}}%1$s',
328326
];
329327
}
330328
}

0 commit comments

Comments
 (0)
0