xref: /aosp_15_r20/external/curl/docs/cmdline-opts/data-urlencode.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-urlencode
5*6236dae4SAndroid Build Coastguard WorkerArg: <data>
6*6236dae4SAndroid Build Coastguard WorkerHelp: HTTP POST data URL encoded
7*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP
8*6236dae4SAndroid Build Coastguard WorkerAdded: 7.18.0
9*6236dae4SAndroid Build Coastguard WorkerCategory: http post upload
10*6236dae4SAndroid Build Coastguard WorkerMulti: append
11*6236dae4SAndroid Build Coastguard WorkerSee-also:
12*6236dae4SAndroid Build Coastguard Worker  - data
13*6236dae4SAndroid Build Coastguard Worker  - data-raw
14*6236dae4SAndroid Build Coastguard WorkerExample:
15*6236dae4SAndroid Build Coastguard Worker  - --data-urlencode name=val $URL
16*6236dae4SAndroid Build Coastguard Worker  - --data-urlencode =encodethis $URL
17*6236dae4SAndroid Build Coastguard Worker  - --data-urlencode name@file $URL
18*6236dae4SAndroid Build Coastguard Worker  - --data-urlencode @fileonly $URL
19*6236dae4SAndroid Build Coastguard Worker---
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard Worker# `--data-urlencode`
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard WorkerPost data, similar to the other --data options with the exception that this
24*6236dae4SAndroid Build Coastguard Workerperforms URL-encoding.
25*6236dae4SAndroid Build Coastguard Worker
26*6236dae4SAndroid Build Coastguard WorkerTo be CGI-compliant, the \<data\> part should begin with a *name* followed by
27*6236dae4SAndroid Build Coastguard Workera separator and a content specification. The \<data\> part can be passed to
28*6236dae4SAndroid Build Coastguard Workercurl using one of the following syntaxes:
29*6236dae4SAndroid Build Coastguard Worker
30*6236dae4SAndroid Build Coastguard Worker## content
31*6236dae4SAndroid Build Coastguard WorkerURL-encode the content and pass that on. Just be careful so that the content
32*6236dae4SAndroid Build Coastguard Workerdoes not contain any `=` or `@` symbols, as that makes the syntax match one of
33*6236dae4SAndroid Build Coastguard Workerthe other cases below.
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard Worker## =content
36*6236dae4SAndroid Build Coastguard WorkerURL-encode the content and pass that on. The preceding `=` symbol is not
37*6236dae4SAndroid Build Coastguard Workerincluded in the data.
38*6236dae4SAndroid Build Coastguard Worker
39*6236dae4SAndroid Build Coastguard Worker## name=content
40*6236dae4SAndroid Build Coastguard WorkerURL-encode the content part and pass that on. Note that the name part is
41*6236dae4SAndroid Build Coastguard Workerexpected to be URL-encoded already.
42*6236dae4SAndroid Build Coastguard Worker
43*6236dae4SAndroid Build Coastguard Worker## @filename
44*6236dae4SAndroid Build Coastguard Workerload data from the given file (including any newlines), URL-encode that data
45*6236dae4SAndroid Build Coastguard Workerand pass it on in the POST. Using `@-` makes curl read the data from stdin.
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard Worker## name@filename
48*6236dae4SAndroid Build Coastguard Workerload data from the given file (including any newlines), URL-encode that data
49*6236dae4SAndroid Build Coastguard Workerand pass it on in the POST. The name part gets an equal sign appended,
50*6236dae4SAndroid Build Coastguard Workerresulting in *name=urlencoded-file-content*. Note that the name is expected to
51*6236dae4SAndroid Build Coastguard Workerbe URL-encoded already.
52