Skip to main content

Curl

Полезная информация по работе с curl.

Использование клиентского сертификата для скачивания

curl -O https://url --cert cert.pem --key client.key --cacert ca.pem

Ограничение скорости закачки

Ключ --limit-rate <speed> Могут быть следующие суффиксы:

  • “k”, “K” - килобайты.
  • “m”, “M” - мегабайты.
  • “g”, “G” - гигабайты.

Например: 200K, 3m или 1G.

Расширенное логирование

Для расширенного логирования необходимо добавить ключ --trace. После ключа необходимо указать файл в который сохранять trace. Если вместо имени файла указать - то информация будет выводится в консоль.

Вывод произвольной информации о загрузке

Для вывода произвольно информации применяется ключ -w. Применяется следующим образом: -w "Download time: %{time_total}, file size: %{size_download}, speed: %{speed_download}\n". Могут использоваться следующие параметры:

ПараметрЗначение
content_typethe Content-Type value of the file
http_codeHTTP(S) code in the page
http_connectHTTP code in the proxy response
num_connectsnumber of new connections made in the transfer
num_redirectsnumber of redirection operations that were made
size_downloadtotal size of downloaded data
size_headertotal size of the headers
size_requesttotal size of the request
size_uploadtotal size of uploaded data
speed_downloadaverage download speed
speed_uploadaverage upload speed
time_connecttime from the start until the remote host connection was made
time_namelookuptime from the start of the command until name resolution was finished
time_pretransfertime from the start until the file transfer was about to begin
time_redirecttime for all redirection operations
time_starttransferall pretransfer time plus the time needed to calculate the result
time_totaltime for the complete operation (to the millisecond)
url_effectivethe last URL fetched