tool_getparam: initial --json support

Adds these test cases:

 383 - simple single command line option
 384 - reading it from stdin
 385 - getting two --json options on command line
 386 - --next works after --json

Closes #8314
This commit is contained in:
Daniel Stenberg 2022-01-21 09:38:44 +01:00
parent 1ce1f0b5a0
commit 32160cae84
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 343 additions and 12 deletions

View file

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
# Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@ -111,6 +111,7 @@ DPAGES = \
interface.d \
ipv4.d \
ipv6.d \
json.d \
junk-session-cookies.d \
keepalive-time.d \
key-type.d \

32
docs/cmdline-opts/json.d Normal file
View file

@ -0,0 +1,32 @@
Long: json
Arg: <data>
Help: HTTP POST JSON
Protocols: HTTP
See-also: data-binary data-raw
Mutexed: form head upload-file
Category: http post upload
Example: --json '{ "drink": "coffe" }' $URL
Example: --json '{ "drink":' --json ' "coffe" }' $URL
Example: --json @prepared $URL
Example: --json @- $URL < json.txt
Added: 7.82.0
---
Sends the specified JSON data in a POST request to the HTTP server. --json
works as a shortcut for passing on these three options:
--data [arg]
--header "Content-Type: application/json"
--header "Accept: application/json"
There is **no verification** that the passed in data is actual JSON or that
the syntax is correct.
If you start the data with the letter @, the rest should be a file name to
read the data from, or a single dash (-) if you want curl to read the data
from stdin. Posting data from a file named \&'foobar' would thus be done with
--json @foobar and to instead read the data from stdin, use --json @-.
If this option is used more than once on the same command line, the additional
data pieces will be concatenated to the previous before sending.
The headers this option sets can be overriden with --header as usual.

View file

@ -99,6 +99,7 @@
--interface 7.3
--ipv4 (-4) 7.10.8
--ipv6 (-6) 7.10.8
--json 7.82.0
--junk-session-cookies (-j) 7.9.7
--keepalive-time 7.18.0
--key 7.9.3