Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[HttpClient] Fix json encode flags usage in copy-as-curl generation#46670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@welcoMattic
Copy link
Member

@welcoMatticwelcoMattic commentedJun 14, 2022
edited
Loading

QA
Branch?6.1
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

Thejson_encode($json, \JSON_PRETTY_PRINT) call to generate the cURL version of a HTTP Request in HttpClientDataCollector didn't use theself::jsonEncode method available.

The main issue with that is the usage of\JSON_PRETTY_PRINT, which is overwrites all other flags inself::jsonEncode method, especially\JSON_PRESERVE_ZERO_FRACTION.

So I have added a test for it:

1) Symfony\Component\HttpClient\Tests\DataCollector\HttpClientDataCollectorTest::testItGeneratesCurlCommandsAsExpected with data set "POST with json" (array('POST', 'http://localhost:8057/json', array(array(array('baz', array(1.1, 1.0))))), 'curl \\n  --compressed \\n  -...n}%1$s')Failed asserting that two strings are equal.--- Expected+++ Actual@@ @@         "bar": "baz",\n         "qux": [\n             1.1,\n-            1.0\n+            1\n         ]\n     }\n }''

After the changes, this test pass ✅

I've added test for all other flags, to be sure that they are used. It could lead to less readable JSON (with hex values) displayed in Profiler, but it's more accurate to debug.

EDIT: removing\JSON_PRETTY_PRINT solve the problem too, and we don't need to pretty-print the JSON in curl command, it allows to run theexact same request.

@welcoMatticwelcoMatticforce-pushed thefix/http-client-data-collector-json-encode branch fromf1392ae to1210828CompareJune 14, 2022 15:53
@welcoMatticwelcoMatticforce-pushed thefix/http-client-data-collector-json-encode branch from1210828 tobb0ddf1CompareJune 16, 2022 08:41
@nicolas-grekas
Copy link
Member

Thank you@welcoMattic.

welcoMattic reacted with heart emoji

@nicolas-grekasnicolas-grekas merged commitb78725a intosymfony:6.1Jun 19, 2022
@fabpotfabpot mentioned this pull requestJun 26, 2022
@welcoMatticwelcoMattic deleted the fix/http-client-data-collector-json-encode branchJuly 6, 2022 09:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas left review comments

@stofstofstof left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.1

Development

Successfully merging this pull request may close these issues.

5 participants

@welcoMattic@nicolas-grekas@dunglas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp