curl

references:

available %-symbols:

  • content_type

  • curl_version

  • errormsg

  • exitcode

  • filename_effective

  • ftp_entry_path

  • http_code - The numerical response code that was found in the last retrieved HTTP(S) or FTP(s) transfer

  • http_connect

  • http_version

  • json

  • local_ip

  • local_port

  • method

  • num_connects

  • num_headers

  • num_redirects

  • proxy_ssl_verify_result

  • redirect_url

  • referer

  • remote_ip

  • remote_port

  • response_code - The numerical response code that was found in the last transfer (formerly known as http_code)

  • scheme

  • size_download

  • size_header

  • size_request

  • size_upload

  • speed_download

  • speed_upload

  • ssl_verify_result

  • stderr

  • stdout

  • time_appconnect

  • time_connect

  • time_namelookup

  • time_pretransfer

  • time_redirect

  • time_starttransfer

  • time_total

  • url

  • url_effective

  • urlnum

  • get via

install via source

[!NOTE|label:references:]

  • environment

    [!TIP]

    • centos:

      • gcc : appstream

      • libssh2 : @epel

      • libssh2-devel : @epel : $ dnf install libssh2 libssh2-devel libssh2-docs

      • libssh2-doc : @epel

      • zlib : @centos-baseos

      • brotli : @centos-baseos : $ sudo dnf install brotli-devel.i686

      • libpsl : @centos-baseos

      • openssl : @centos-baseos

      • libidn2 : @centos-baseos

  • build

    [!NOTE|label:references]

    • --prefix=/usr/local will install in :

      • /usr/local/lib

      • /usr/local/bin

      • /usr/local/include

      • /usr/local/share

  • full configure

  • for issue: undefined reference to 'BrotliDecoderCreateInstance':

    • solution:

  • set

    [!NOTE|label:OPTIONAL] no need if using /usr/local as --prefix

  • check

[!NOTE|label:references:]

get

get http_code for multiple urls

  • or

  • or

post

put

delete

syntax:

authorization

content type

others

ssl

ignore invalid and self-signed SSL certificate errors in Curl

make HTTPS requests with Curl

with SSL connections

convert

  • get resource content by url

  • save url content to a file

  • download multiple files at once

  • check page http headers

  • force curl to use http/2 protocol

  • do follow redirects

  • use proxy server

  • provide additional http headers with request

  • send data to the server

  • change the user-agent string

  • send cookies to website

references

Flags
Description
Syntax

-O

Download the file and save it under the original name

curl -O [URL]

-o

Download the file and save it with a different name

curl -o [file name] [URL]

-X

Specify the HTTP method to be used when sending the request

curl -X [method] [URL]

-I or -head

Print the title without the body of the document

curl -I [URL]

-d

Specify the data to send to the server

curl -d "key1=value1&key2=value2" [URL]

-k or -insecure

Ignore SSL Certificate Errors

curl -k [URL]

-u or --user

Specify the authentication data by passing a pair of login-password

curl -u [user:password] [URL]

-F

Submit form data as POST request

curl -F @field_name=@path/to/myFile

--cookie

Send HTTP cookies

curl --cookie "Name=Value" [URL]

-x or --proxy

Use a proxy server to upload files

curl -x "[protocol://][host][:port]" [URL] [options]

--limit-rate

Limit the download speed

curl --limit-rate [speed] -O [URL]

-L or --location

Follow Curl redirect using HTTP Location header

curl -L [URL]

-v

Makes Curl verbose

curl -v [URL]

-m or --max-time

Set a limit in seconds for the entire operation

curl -m [SECONDS] [URL]

--connect-timeout

Set a limit in seconds for a connection request

curl --connect-timeout [SECONDS] [URL]

-T

Transfers the specified local file to a remote URL

curl -T [file name] [URL]

-H or --header

Add additional HTTP request header

curl -H "X-Header: value" [URL]

-D

Save the HTTP headers that the site sends back

curl -D [URL]

-A or --user-agent

Set User-Agent string

curl -A "value" [URL]

-C

Resume an interrupted or intentionally stopped download

curl -C [OFFSET] -O [URL]

write-out

Option
Description

Lookup time (time_namelookup)

The time, in seconds, it took from the start until the name resolving was completed

Connect time (time_connect)

The time, in seconds, it took from the start until the TCP connect to the remote host was completed

PreXfer time (time_pretransfer)

The time, in seconds, it took from the start until the file transfer was just about to begin. This includes all β€˜pre-transfer’ commands and negotiations that are specific to the particular protocol(s) involved

StartXfer time (time_starttransfer)

The time, in seconds, it took from the start until the first byte was just about to be transferred. This includes β€˜time_pretransfer’ and also the time the server needed to calculate the result

AppCon time (time_appconnect)

The time, in seconds, it took from the start until the SSL/SSH/etc connect/handshake to the remote host was completed (Added in 7.19.0)

Redirect time (time_redirect)

The time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before the final transaction was started. β€˜time_redirect’ shows the complete execution time for multiple redirections. (Added in 7.12.3)

Last updated

Was this helpful?