CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier...
Transcript of CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier...
![Page 1: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/1.jpg)
CURLCURLYLMRXYLMRX
Created: 2019-07-03 Wed 11:43
1
![Page 2: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/2.jpg)
ABOUTABOUTYoann "fuzzy" Lamouroux:
Reverse-engineer and security expert @dataimpact(we're hiring ��� )Former sysadminTrol ˆ Wdocumented opinions:
xoxopowo@twitter
![Page 3: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/3.jpg)
ABOUT LAST YEARABOUT LAST YEAR
![Page 4: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/4.jpg)
ABOUT LAST YEARABOUT LAST YEAR5' is short (except when prod is down)
![Page 5: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/5.jpg)
ABOUT LAST YEARABOUT LAST YEAR5' is short (except when prod is down)Now I have 20 (w00t)
![Page 6: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/6.jpg)
ABOUT LAST YEARABOUT LAST YEAR5' is short (except when prod is down)Now I have 20 (w00t)I hope I deal better with time
![Page 7: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/7.jpg)
ABOUT LAST YEARABOUT LAST YEAR5' is short (except when prod is down)Now I have 20 (w00t)I hope I deal better with time(so I made a slide about dealing with time)
![Page 8: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/8.jpg)
ABOUT LAST YEARABOUT LAST YEAR5' is short (except when prod is down)Now I have 20 (w00t)I hope I deal better with time(so I made a slide about dealing with time)No more curling jokes (sorry)
![Page 9: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/9.jpg)
TRIVIATRIVIAProject started in 1996Still maintained by Daniel Stenberg (@badger)libcurl for about every language out thereThe curl binary is in EVERY default install
![Page 10: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/10.jpg)
ALL OF THEMALL OF THEM
![Page 11: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/11.jpg)
ALL OF THEMALL OF THEMGNU/Linux, *BSD
![Page 12: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/12.jpg)
ALL OF THEMALL OF THEMGNU/Linux, *BSDMacOS
![Page 13: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/13.jpg)
ALL OF THEMALL OF THEMGNU/Linux, *BSDMacOSWindows 10 (recently)
![Page 14: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/14.jpg)
SOME QUESTIONSSOME QUESTIONScurl is oldcurl is badly documented (?)DevTools (Firefox, Chrome) is goodhttpie is neater/prettierpython-requests
![Page 15: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/15.jpg)
SOME ANSWERSSOME ANSWERSOld means:
GoodStable/reliable
DevTools are indeed goodhttpie is a curl wrapperpython-requests is python (hang-on, brb)
![Page 16: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/16.jpg)
DOCUMENTATIONDOCUMENTATIONYou usually need curl in critical situationsNo time to dig through 3k lines manual
![Page 17: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/17.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:
![Page 18: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/18.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxies
![Page 19: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/19.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes
![Page 20: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/20.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})
![Page 21: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/21.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})… whatever cool kids use these days
![Page 22: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/22.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})… whatever cool kids use these daysAnd shiny boxes (aka. docker)
![Page 23: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/23.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})… whatever cool kids use these daysAnd shiny boxes (aka. docker)Tighter firewall policy (aka. no internets)
![Page 24: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/24.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})… whatever cool kids use these daysAnd shiny boxes (aka. docker)Tighter firewall policy (aka. no internets)Just because you can run Chrome in docker,
![Page 25: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/25.jpg)
EVERYWHEREEVERYWHEREDevTools won't get you far beyond the browserToday's IT imply:Reverse-proxiesCloudy jokes(aka. mai', aka. Kloug{Front,Flare,…})… whatever cool kids use these daysAnd shiny boxes (aka. docker)Tighter firewall policy (aka. no internets)Just because you can run Chrome in docker,… doesn't mean you should
![Page 26: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/26.jpg)
![Page 27: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/27.jpg)
![Page 28: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/28.jpg)
![Page 29: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/29.jpg)
![Page 30: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/30.jpg)
BASICSBASICS
Display body on stdout.
>> curl https://www.example.com/
![Page 31: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/31.jpg)
VERBOSEVERBOSE curl -v https://httpbin.org > /dev/null * Rebuilt URL to: https://httpbin.org/ % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 34.230.136.58... * TCP_NODELAY set * Connected to httpbin.org (34.230.136.58) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs } [5 bytes data] * (304) (OUT), TLS handshake, Client hello (1): } [512 bytes data] * (304) (IN), TLS handshake, Server hello (2): { [89 bytes data] * TLSv1.2 (IN), TLS handshake, Certificate (11): { [4832 bytes data] * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
![Page 32: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/32.jpg)
PREFIXES:PREFIXES:* : is information> : protocol verbose FROM your computer (*)< : protocol verbose TO your computer (*)} : encrypted data FROM your computer{ : encrypted data TO your computer[xxx] : size (in bytes) of data transferred.
(ssl verbose with brackets is shown only when stdout is redirected)
(*) : doesn't mean it's not encrypted
![Page 33: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/33.jpg)
MORE VERBOSEMORE VERBOSEtcpdump might not be the answer (yet).
--trace and --trace-ascii for byte-per-byte analysis.
Use - or filename as an argument to write to stdout or to a file.
![Page 34: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/34.jpg)
CUSTOM HEADERSCUSTOM HEADERS-H (or --header) : to send custom headersAdd 'Key: Value' for each headers-A foo: is a shortcut to -H 'User-Agent: foo'-b foo=bar: is a shortcut to -H 'Cookie: foo=bar'
(Cookies are just headers your browser is used to save)
![Page 35: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/35.jpg)
COOKIESCOOKIESNot saved by defaultUse -c to save cookies to a file (- to display on stdout)Use -b to read from a file (it won't by default)
![Page 36: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/36.jpg)
TIMER AFTER TIMETIMER AFTER TIME
![Page 37: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/37.jpg)
Have-you ever seen this ?:
time curl http://example.org
![Page 38: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/38.jpg)
TRY :TRY :curl --trace-time -v http://example.org
(Only works in verbose or trace mode)
![Page 39: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/39.jpg)
TRY :TRY :curl --trace-time -v http://example.org
(Only works in verbose or trace mode)
Unless you do want to check the cpu-time / user-time of an HTTPclient request.
![Page 40: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/40.jpg)
TRY :TRY :curl --trace-time -v http://example.org
(Only works in verbose or trace mode)
Unless you do want to check the cpu-time / user-time of an HTTPclient request.
(you don't)
![Page 41: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/41.jpg)
ANOTHER APPROACHANOTHER APPROACHYou can write many variables on output, with the format string
option including:
Request information:http_code
http_version
Time and speed:time_total
speed_download
Many more…
![Page 42: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/42.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
![Page 43: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/43.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
We can also mention --stderr to control the error output
![Page 44: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/44.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
We can also mention --stderr to control the error outputUse with - to direct it to stdout
![Page 45: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/45.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
We can also mention --stderr to control the error outputUse with - to direct it to stdoutOr whatever filename
![Page 46: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/46.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
We can also mention --stderr to control the error outputUse with - to direct it to stdoutOr whatever filename>15 years using shells, still can't handle std flows ?
![Page 47: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/47.jpg)
FOR EXAMPLE:FOR EXAMPLE:
Introducing -oOUTFILE, much prettier than ">/dev/null"Also introducing the -s (--silent) option to inhibit the uglyprogress metric
curl -w "http/%{http_version} %{http_code} -- %{time_total}" -s -o/dev/null http://example.com
We can also mention --stderr to control the error outputUse with - to direct it to stdoutOr whatever filename>15 years using shells, still can't handle std flows ?curl got your back.
![Page 48: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/48.jpg)
DID YOU EVER ?DID YOU EVER ?
![Page 49: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/49.jpg)
DID YOU EVER ?DID YOU EVER ?…
![Page 50: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/50.jpg)
DID YOU EVER ?DID YOU EVER ?…
Need to edit /etc/hosts ?
![Page 51: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/51.jpg)
DID YOU EVER ?DID YOU EVER ?…
Need to edit /etc/hosts ?
curl -v --resolve www.example.com:443:1.2.3.4 https://www.example.com/
![Page 52: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/52.jpg)
DID YOU EVER ?DID YOU EVER ?…
Need to edit /etc/hosts ?
No need to play around with "Host" header
curl -v --resolve www.example.com:443:1.2.3.4 https://www.example.com/
![Page 53: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/53.jpg)
MEMORY ALLOCATIONMEMORY ALLOCATIONPROBLEMSPROBLEMS
![Page 54: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/54.jpg)
MEMORY ALLOCATIONMEMORY ALLOCATIONPROBLEMSPROBLEMS
No. Don't.
![Page 55: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/55.jpg)
MEMORY ALLOCATIONMEMORY ALLOCATIONPROBLEMSPROBLEMS
No. Don't.
All the options I mentioned can be added to $HOME/.curlrc
![Page 56: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/56.jpg)
MEMORY ALLOCATIONMEMORY ALLOCATIONPROBLEMSPROBLEMS
No. Don't.
All the options I mentioned can be added to $HOME/.curlrc
Or write several of these, and recall them with -K filename, or--config
![Page 57: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/57.jpg)
CURL PLAYS NICE WITHCURL PLAYS NICE WITHOTHERSOTHERS
Or you can avoid the options madness and ordering, by just right-clicking in Firefox (and Chrome) DevTools.
![Page 58: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/58.jpg)
CURL PLAYS NICE WITHCURL PLAYS NICE WITHOTHERSOTHERS
Or you can avoid the options madness and ordering, by just right-clicking in Firefox (and Chrome) DevTools.
And select "Copy as cURL"
![Page 59: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/59.jpg)
CURL PLAYS NICE WITHCURL PLAYS NICE WITHOTHERSOTHERS
Or you can avoid the options madness and ordering, by just right-clicking in Firefox (and Chrome) DevTools.
And select "Copy as cURL"
It works in BurpSuite too.
![Page 60: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/60.jpg)
CURL PUTS THE C IN CURL.CURL PUTS THE C IN CURL.> curl https://example.com \ --header "Hello: World" -w '# %{http_code} -- %{time_total}'\ --libcurl test.c -so/dev/null# 200 -- 0,339792%> cat test.c
![Page 61: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/61.jpg)
TEST.CTEST.C/********* Sample code generated by the curl command line tool ********** * All curl_easy_setopt() options are documented at: * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html ************************************************************************/#include <curl/curl.h>
int main(int argc, char *argv[]){ CURLcode ret; CURL *hnd;struct curl_slist *slist1;
slist1 = NULL; slist1 = curl_slist_append(slist1, "Hello: World");
hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); curl_easy_setopt(hnd, CURLOPT_URL, "https://example.com"); curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
![Page 62: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/62.jpg)
YOUR OWN STRESS-TESTYOUR OWN STRESS-TESTBecause after all, they're just glorified (yet customisable)loops with precise metricsLet's roll our own apache-bench
![Page 63: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/63.jpg)
#include <curl/curl.h>#include <omp.h>#define MAX_THREAD 64#define LASERS 1000#define URL "http://www.example.com"
int main(int argc, char *argv[]) {int tid, i = 0;
FILE *devnull; devnull = fopen("/dev/null", "w");#pragma omp parallel private(i) num_threads(MAX_THREAD)
{#pragma omp for
for(i = 0; i < LASERS; ++i) { tid = omp_get_thread_num();
CURLcode ret; CURL *hnd;
double total;curl_off_t dl, rate;
![Page 64: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/64.jpg)
Just removing some comments
#include <curl/curl.h>#include <omp.h>#define MAX_THREAD 64#define LASERS 1000#define URL "http://www.example.com"
int main(int argc, char *argv[]) {int tid, i = 0;
FILE *devnull; devnull = fopen("/dev/null", "w");#pragma omp parallel private(i) num_threads(MAX_THREAD)
{#pragma omp for
for(i = 0; i < LASERS; ++i) { tid = omp_get_thread_num();
CURLcode ret; CURL *hnd;
double total;curl_off_t dl, rate;
![Page 65: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/65.jpg)
Just removing some commentsAnd wrap some OpenMP magic around
#include <curl/curl.h>#include <omp.h>#define MAX_THREAD 64#define LASERS 1000#define URL "http://www.example.com"
int main(int argc, char *argv[]) {int tid, i = 0;
FILE *devnull; devnull = fopen("/dev/null", "w");#pragma omp parallel private(i) num_threads(MAX_THREAD)
{#pragma omp for
for(i = 0; i < LASERS; ++i) { tid = omp_get_thread_num();
CURLcode ret; CURL *hnd;
double total;curl_off_t dl, rate;
![Page 66: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/66.jpg)
Just removing some commentsAnd wrap some OpenMP magic aroundCompile with: gcc mt_curl.c -fopenmp -lcurl
#include <curl/curl.h>#include <omp.h>#define MAX_THREAD 64#define LASERS 1000#define URL "http://www.example.com"
int main(int argc, char *argv[]) {int tid, i = 0;
FILE *devnull; devnull = fopen("/dev/null", "w");#pragma omp parallel private(i) num_threads(MAX_THREAD)
{#pragma omp for
for(i = 0; i < LASERS; ++i) { tid = omp_get_thread_num();
CURLcode ret; CURL *hnd;
double total;curl_off_t dl, rate;
![Page 67: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/67.jpg)
Just removing some commentsAnd wrap some OpenMP magic aroundCompile with: gcc mt_curl.c -fopenmp -lcurlMake sure the entire file is <42 LoC
#include <curl/curl.h>#include <omp.h>#define MAX_THREAD 64#define LASERS 1000#define URL "http://www.example.com"
int main(int argc, char *argv[]) {int tid, i = 0;
FILE *devnull; devnull = fopen("/dev/null", "w");#pragma omp parallel private(i) num_threads(MAX_THREAD)
{#pragma omp for
for(i = 0; i < LASERS; ++i) { tid = omp_get_thread_num();
CURLcode ret; CURL *hnd;
double total;curl_off_t dl, rate;
![Page 68: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/68.jpg)
DEMO ?DEMO ?
![Page 69: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/69.jpg)
THANK YOUTHANK YOUEveryone @ PTS for all the eventDan Stanberg for all of the curlingHave a safe trip back home ♥
![Page 70: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/70.jpg)
![Page 71: CURLCURL - Pass the SALT Conference · DevTools (Firefox, Chrome) is good httpie is neater/prettier python-requests. SOME ANSSOME ANSWERSWERS Old means: Good Stable/reliable DevTools](https://reader033.fdocuments.net/reader033/viewer/2022042420/5f37aade46fdc04d74312656/html5/thumbnails/71.jpg)
QUESTIONS ?QUESTIONS ?���