Инструменты пользователя

Инструменты сайта


how-to:curl

cURL

Скачать файл в директорию /tmp:

curl -sL -O https://raw.githubusercontent.com/user/project/branch/file.tgz -P /tmp

HTTPS

Игнорировать ошибки сертификатов (self-signed)

Параметр: -k, –insecure:

curl --insecure https://...

Работа через proxy

Параметр: -x, –proxy и -U, –proxy-user:

curl --proxy http://d2proxy.domain.com:3128/ -U username:password http://...

GET

Пример запроса с выводом только куки значения «Expires»:

curl -s -X GET -k -i 'https://ya.ru' | sed -n 's/Set-Cookie: mda=0; Expires=\([a-zA-Z0-9\,: \-]*\).*/\1/p'

POST

Пример запроса с выводом времени выполнения:

curl -X POST "https://ibmdemows.idscan.net/VSWebServices67/CustomFields/Tree" -H "Content-Type: application/json" -d '{"Login":"zebra","Password":"zebra123qwe!@#QWE"}' -w "\nTime:%{time_total}\n"

Дополнительная информация по запросу (-w)

curl-format.txt:

time_namelookup:  %{time_namelookup}\n
time_connect:  %{time_connect}\n
time_appconnect:  %{time_appconnect}\n
time_pretransfer:  %{time_pretransfer}\n
time_redirect:  %{time_redirect}\n
time_starttransfer:  %{time_starttransfer}\n
time_total:  %{time_total}\n
curl -w "@curl-format.txt" -o /dev/null -s http://wordpress.com/

https://blog.josephscott.org/2011/10/14/timing-details-with-curl/

Resolve

Проверить web сервер не используя dns:

curl -H 'Host: domain.com' http://127.0.0.1/path

или

curl --resolve 'domain.com:80:127.0.0.1' http://127.0.0.1/path

по https:

curl --resolve 'domain.com:443:192.0.2.17' https://domain.com

Сжатие

Проверить на сжатие $URL:

curl $URL --silent --write-out "%{size_download}\n" --output /dev/null
curl $URL --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null

https://stackoverflow.com/questions/9140178/how-can-i-tell-if-my-server-is-serving-gzipped-content

Ошибки

how-to/curl.txt · Последнее изменение: lioncub