cURL

cURL which stands for "client for URL" is a useful networking tool that can be used in command lines or scripts for transferring data. It supports multiple protocols.

Basic commands:

# Basic
$ curl -X <method> <HTTP_URL>

# With headers
$ curl -X <method> -H <headers> <HTTP_URL>

# GET: no need to specify the -X flag
$ curl -H <headers> <HTTP_URL>

# VERBOSE: increasing level of output
$ curl ... -v
$ curl ... -vv
$ curl ... -vvv

Examples

Sending a GET request to https://domain.com with query data

$ curl https://domain.com?key=value

POST

x-www-form-urlencoded

Eg. Sending a POST request to https://domain.com with some x-www-form-urlencoded data.

json

Eg. Sending a POST request to https://domain.com with some json data.

Form-data

The @ and < symbols can be used to read contents from a file for file upload and text field respectively.

From the cURL documentation:

To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.

SOCKS5 proxy

To make the proxy handle DNS resolutions, for privacy concerns, etc. This means that there will be no local address resolution.

The --socks5-hostname or -x socks5h:// options can be used instead.

curl documentation

Last updated