Use proper quoting in HTTPie shell commands#29
Merged
ahmadnassri merged 1 commit intoKong:masterfrom Mar 17, 2015
jkbrzt:master
Merged
Use proper quoting in HTTPie shell commands#29ahmadnassri merged 1 commit intoKong:masterfrom jkbrzt:master
ahmadnassri merged 1 commit intoKong:masterfrom
jkbrzt:master
Conversation
Before, the resultant shell command was completely unquoted. This change
introduces proper quoting of values and the URL - when necessary.
It uses single quotes which provide "strong quoting" (only nested single quote
characters need to be taken care of) and also make the output more
readable as double quotes, ubiquitous in JSON, don't require escaping.
Before:
echo "{\"foo\": \"bar\"}" | \
http POST http://mockbin.com/request?foo=bar&foo=baz \
accept:application/json \
content-type:application/json \
cookie:foo=bar; bar=baz
After:
echo '{"foo": "bar"}' | \
http POST 'http://mockbin.com/request?foo=bar&foo=baz' \
accept:application/json \
content-type:application/json \
cookie:'foo=bar; bar=baz'
Member
|
👍 |
|
nice 👍 thanks @jakubroztocil I will integrate this with curl and wget as well. |
ahmadnassri
added a commit
that referenced
this pull request
Mar 17, 2015
Use proper quoting in HTTPie shell commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This looks like an interesting project 👍 I've noticed a problem with quoting of the shell commands and this pull request fixes that for HTTPie:
Before, the resultant shell command was completely unquoted. This change introduces proper quoting of values and the URL - when necessary.
It uses single quotes which provide "strong quoting" (only nested single quote characters need to be taken care of) and also make the output more readable as double quotes, ubiquitous in JSON, don't require escaping.
Before:
After:
The cURL command (and possible also Wget) most likely suffer from improper quoting as well. It's not completely missing, as was the case of HTTPie, but it uses double quotes so literals like
"foo bar $HOME baz"might get expanded by the shell. I think the same quoting mechanism should be used there as well.