Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_curl: Improve quoting, update options #200

Merged
merged 5 commits into from
Jan 22, 2022

Conversation

blyxxyz
Copy link
Collaborator

@blyxxyz blyxxyz commented Nov 26, 2021

The quoting done by shell-escape is very simple and conservative, not great for user-readable output. I recently wrote os_display which I think is more suitable here.

I also went through all the options to bring them up to date.

@blyxxyz
Copy link
Collaborator Author

blyxxyz commented Nov 27, 2021

The ARM tests get stuck on inferred_json_javascript_output. I can't reproduce that locally, and it seems impossible for it to be caused by these commits, so I don't know what's going on.

@ducaale
Copy link
Owner

ducaale commented Nov 27, 2021

All tests have passed now (there is proxy_all_proxy that fails silently but it can be adressed in a later PR).

If ARM tests start to fail again, perhaps we could try limiting the number of parallel qemu-arm invocations in integration tests?

src/to_curl.rs Outdated Show resolved Hide resolved
src/to_curl.rs Outdated Show resolved Hide resolved
src/to_curl.rs Show resolved Hide resolved
@blyxxyz blyxxyz marked this pull request as draft November 27, 2021 17:07
@blyxxyz blyxxyz marked this pull request as ready for review January 22, 2022 17:15
@blyxxyz
Copy link
Collaborator Author

blyxxyz commented Jan 22, 2022

I haven't done a new os_display release yet, I'll do that if this looks ok.

@ducaale
Copy link
Owner

ducaale commented Jan 22, 2022

Yup, I can confirm the quoting works correctly in Powershell now.

cargo run -- httpbin.org/post x=3 --curl
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
     Running `target\debug\xh.exe httpbin.org/post x=3 --curl`
curl http://httpbin.org/post -H 'content-type: application/json' -H 'accept: application/json, */*;q=0.5' -d '{\"x\":\"3\"}'

PS C:\Users\shara\Desktop\projects\xh> curl http://httpbin.org/post -H 'content-type: application/json' -H 'accept: application/json, */*;q=0.5' -d '{\"x\":\"3\"}'
{
  "args": {},
  "data": "{\"x\":\"3\"}",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "application/json, */*;q=0.5",
    "Content-Length": "9",
    "Content-Type": "application/json",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.79.1",
    "X-Amzn-Trace-Id": "Root=1-61ec4860-1bf0ad7325e7ce3746ae47ca"
  },
  "json": {
    "x": "3"
  },
  "origin": "92.40.172.172",
  "url": "http://httpbin.org/post"
}

We do this by switching from shell-escape to os_display. That one
doesn't quote unless necessary and supports invalid unicode.
src/to_curl.rs Outdated Show resolved Hide resolved
Copy link
Owner

@ducaale ducaale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 🎉

@ducaale ducaale merged commit 88a3705 into ducaale:develop Jan 22, 2022
@blyxxyz blyxxyz deleted the improve-curl branch January 22, 2022 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants