application/x-www-form-urlencoded
content type, such as the ones curl sends with --data
and --data-binary
etc.--data-urlencode
option. This option offers several different ways to URL encode the data you give it.--data-urlencode data
in the same style as the other --data options. 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
: This will make curl URL encode the content and pass that on. Just be careful so that the content does not contain any = or @ symbols, as that will then make the syntax match one of the other cases below!=content
: This will make curl URL encode the content and pass that on. The initial '=' symbol is not included in the data.name=content
: This will make curl URL encode the content part and pass that on. Note that the name part is expected to be URL encoded already.@filename
: This will make curl load data from the given file (including any newlines), URL encode that data and pass it on in the POST.[email protected]
: This will make curl 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.John Doe (Junior)
in a file named contents.txt
, you can tell curl to send that contents URL encoded using the field name 'user' like this:user name
, you can ask curl to encode the entire string by prefixing it with an equals sign (that will not get sent):