File: data-urlencode.md

package info (click to toggle)
curl 8.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 31,884 kB
  • sloc: ansic: 200,254; perl: 21,116; python: 10,390; sh: 6,691; makefile: 1,507; pascal: 240; cpp: 196
file content (51 lines) | stat: -rw-r--r-- 1,595 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
SPDX-License-Identifier: curl
Long: data-urlencode
Arg: <data>
Help: HTTP POST data URL encoded
Protocols: HTTP
Added: 7.18.0
Category: http post upload
Multi: append
See-also:
  - data
  - data-raw
Example:
  - --data-urlencode name=val $URL
  - --data-urlencode =encodethis $URL
  - --data-urlencode name@file $URL
  - --data-urlencode @fileonly $URL
---

# `--data-urlencode`

Post data, similar to the other --data options with the exception that this
performs URL-encoding.

To be CGI-compliant, the \<data\> part should begin with a *name* followed by
a separator and a content specification. The \<data\> part can be passed to
curl using one of the following syntaxes:

## content
URL-encode the content and pass that on. Be careful so that the content does
not contain any `=` or `@` symbols, as that makes the syntax match one of the
other cases below.

## =content
URL-encode the content and pass that on. The preceding `=` symbol is not
included in the data.

## name=content
URL-encode the content part and pass that on. Note that the name part is
expected to be URL-encoded already.

## @filename
load data from the given file (including any newlines), URL-encode that data
and pass it on in the POST. Using `@-` makes curl read the data from stdin.

## name@filename
load data from the given file (including any newlines), URL-encode that data
and pass it on in the POST. The name part gets an equal sign appended,
resulting in *name=urlencoded-file-content*. Note that the name is expected to
be URL-encoded already.