xref: /aosp_15_r20/external/curl/docs/cmdline-opts/data.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: data
5*6236dae4SAndroid Build Coastguard WorkerShort: d
6*6236dae4SAndroid Build Coastguard WorkerArg: <data>
7*6236dae4SAndroid Build Coastguard WorkerHelp: HTTP POST data
8*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP MQTT
9*6236dae4SAndroid Build Coastguard WorkerMutexed: form head upload-file
10*6236dae4SAndroid Build Coastguard WorkerCategory: important http post upload
11*6236dae4SAndroid Build Coastguard WorkerAdded: 4.0
12*6236dae4SAndroid Build Coastguard WorkerMulti: append
13*6236dae4SAndroid Build Coastguard WorkerSee-also:
14*6236dae4SAndroid Build Coastguard Worker  - data-binary
15*6236dae4SAndroid Build Coastguard Worker  - data-urlencode
16*6236dae4SAndroid Build Coastguard Worker  - data-raw
17*6236dae4SAndroid Build Coastguard WorkerExample:
18*6236dae4SAndroid Build Coastguard Worker  - -d "name=curl" $URL
19*6236dae4SAndroid Build Coastguard Worker  - -d "name=curl" -d "tool=cmdline" $URL
20*6236dae4SAndroid Build Coastguard Worker  - -d @filename $URL
21*6236dae4SAndroid Build Coastguard Worker---
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard Worker# `--data`
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerSends the specified data in a POST request to the HTTP server, in the same way
26*6236dae4SAndroid Build Coastguard Workerthat a browser does when a user has filled in an HTML form and presses the
27*6236dae4SAndroid Build Coastguard Workersubmit button. This option makes curl pass the data to the server using the
28*6236dae4SAndroid Build Coastguard Workercontent-type application/x-www-form-urlencoded. Compare to --form.
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard Worker--data-raw is almost the same but does not have a special interpretation of
31*6236dae4SAndroid Build Coastguard Workerthe @ character. To post data purely binary, you should instead use the
32*6236dae4SAndroid Build Coastguard Worker--data-binary option. To URL-encode the value of a form field you may use
33*6236dae4SAndroid Build Coastguard Worker--data-urlencode.
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard WorkerIf any of these options is used more than once on the same command line, the
36*6236dae4SAndroid Build Coastguard Workerdata pieces specified are merged with a separating &-symbol. Thus, using
37*6236dae4SAndroid Build Coastguard Worker'-d name=daniel -d skill=lousy' would generate a post chunk that looks like
38*6236dae4SAndroid Build Coastguard Worker'name=daniel&skill=lousy'.
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard WorkerIf you start the data with the letter @, the rest should be a filename to read
41*6236dae4SAndroid Build Coastguard Workerthe data from, or - if you want curl to read the data from stdin. Posting data
42*6236dae4SAndroid Build Coastguard Workerfrom a file named 'foobar' would thus be done with --data @foobar. When --data
43*6236dae4SAndroid Build Coastguard Workeris told to read from a file like that, carriage returns, newlines and null
44*6236dae4SAndroid Build Coastguard Workerbytes are stripped out. If you do not want the @ character to have a special
45*6236dae4SAndroid Build Coastguard Workerinterpretation use --data-raw instead.
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard WorkerThe data for this option is passed on to the server exactly as provided on the
48*6236dae4SAndroid Build Coastguard Workercommand line. curl does not convert, change or improve it. It is up to the
49*6236dae4SAndroid Build Coastguard Workeruser to provide the data in the correct form.
50