Curl Slideshow
Curl Slideshow
UploadLoginSignup
D
DanielStenberg7
Follow
Technology
Daniel Stemberg's presentation on how curl works. From the basic command line
use, to URLs, options, curl basics into HTTP specifics. YouTube:
https://youtu.be/V5vZWHP-RqU?si=IkGJdHqvguYLffeG
Read more
mastering the curl command line.pdf
4 of 154
Download Now
Save slide
Recommended
How to Prepare For a Successful Job Search for 2024 by
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media
Age(ncy)
2.7K views•96 slides
Trends In Paid Search: Navigating The Digital Landscape In 2024 by
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
1.8K views•31 slides
5 Public speaking tips from TED - Visualized summary by
Design thinking
Manik Choudhary •5.2K views
Problem solving& Decision Making by
Problem Solving
Miles Berry•4.3K views
System Development Life Cycle (SDLC) by
Molded Breakers.docx
Pitiakin•10 views
OpenText Cybersecurity Tabletop Exercise by
We are among the first people who started deploying Open source Telephony
sol...
dvcom2•13 views
Presentation on Algorithms and Flowcharts by
Presentation on Algorithms and Flowcharts
RAKSHITDOGRA1•5 views
TRP-369.pdf by
TRP-369.pdf
Friendly Technologies•9 views
ADI Program Information Webinar by
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking•7.3K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... by
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them
well
Saba Software•25.3K views
Introduction to C Programming Language by
responding 100 means: 👍 - go ahead If it bothers you, disable with curl -H Expect:
https://example.com/ Commonly ignored by servers, leading to wasted waiting time @bagder
123. HTTP POST: chunked Sends data without specifying the size up front For HTTP/1.1 only
curl -H "Transfer-Encoding: chunked" -d @file http://example.com @bagder
124. HTTP POST: <form> The HTML <form> tag is “filled in” with a POST type=hidden fields
as well -d name1=var1 -d name2=var2 -d name3=var3 … The action=[here] identifies where to
send the POST “Copy as curl” is your friend @bagder
125. HTTP multipart formpost This is a POST sending data in a special multipart format
Content-Type multipart/form-data The data is sent as a series of “parts”, one or more Each part
has a name, separate headers, file name and more Each part is separated by a “mime boundary”
@bagder
126. HTTP multipart formpost curl -F [content] adds one part per instance Use as many -F as
you like Insert plain text content -F “name=Daniel Stenberg” Insert content from a file -F
name=<file.txt Insert a file as an “upload” -F name=@file.jpg Insert a file, different file name -F
name=@file.jpg;filename=fake.jpg Set a custom content-type: -F
name=@file.jpg;type=image/myown <form action="submit" method="post"
enctype="multipart/form-data"> @bagder
127. HTTP -d or -F Both sends HTTP POST Both works over every HTTP version Both can “fill
in” HTML <form> What data do you need to send? Very rarely can the client decide. Do what the
server expects! @bagder
128. HTTP redirects The response you want is … over there! HTTP/1.1 301 Server: example-
server/1.1 Location: https://example.com/over-here.html hello A 30X response code + Location:
header tell curl to “follow” with --location (-L) curl -L curl.se curl -L curl.se --max-redirs 7 The
numeric code defines method in redirected-to request --location-trusted Avoid -X @bagder
129. HTTP modify the request Sensible and basic by default You as a user add the bells and
whistles Modify the method with --request Add/change/remove/blank headers with --header curl -
H "curl-master: very-soon" http://example.com/ curl -H "Host: test.example" http://example.com/
curl -H "User-agent:" http://example.com/ curl -H "User-agent;" http://example.com/ @bagder
130. HTTP modify the request The request “target” is made from the URL path + query GET
/user/profile?shoesize=12 HTTP/1.1 User-agent: curl/8.2.1 Host: example.com curl -X OPTIONS
--request-target "*" http://example.com/ Convenient shortcuts: --user-agent [string] --referer
[URL] (yes spelled wrong) Remember “copy as curl” @bagder
131. HTTP PUT The “upload file” of HTTP (and others) curl -T localfile
https://example.com/destination/replacement curl -T -
https://example.com/destination/replacement curl -T file https://example.com curl -T "img[1-
1000].png" http://example.com/images/ curl --upload-file "{file1,file2}" https://example.com curl
-d "data to PUT" -X PUT http://example.com/new/resource/file @bagder
132. HTTP cookies: an explainer key/value pairs that a client stores on the behalf of a server sent
back in subsequent requests only when the cookie properties match each cookie has an expiration
date - or end of “session” A session typically ends when user closes browser When running curl
command lines, when do you close the browser? @bagder
133. HTTP cookies: send some you can tell curl to send specific cookies name + values curl -b
“name=daniel;talks=alot” https://example.com rarely what you want Often what “copy as curl”
will give you @bagder
134. HTTP cookies: start the engine curl ignores cookies by default needs the cookie engine
enabled first specify a file to read from or use a blank string curl -b “” https://example.com More
practically combined with redirect follows curl -L -b “” https://example.com The cookie engine
keeps the cookies in memory it forgets cookies that expire only sends cookies according to the
rules @bagder
135. HTTP cookies: cookie jar Maybe also combined with saving a cookie jar Writes the in-
memory cookies to the given file at exit curl -L -b “” -c cookies.txt https://example.com Read
from and write to the cookie jar (can be different files) curl -L -b cookies.txt -c cookies.txt
https://example.com The cookie jar is a readable text file The cookie jar uses the “netscape cookie
format” Also includes “session cookies” because … sessions @bagder
136. HTTP cookies: session curl does not know when a “session” ends you need to say when a
new cookie session starts --junk‐session‐cookies curl -J -b cookies.txt https://example.com
@bagder
137. HTTP version 2 changed how data is sent over the wire curl hides those differences from
users curl tries to negotiate HTTP/2 for all HTTPS transfers with --http2 you can ask for HTTP/2
for HTTP:// transfers With HTTP/2, curl can do multiplexed transfers with -Z @bagder
138. HTTP version 3 changed how data is sent over the wire - again HTTP/3 is done over QUIC,
a new transport protocol QUIC replaces TCP + TLS, and runs over UDP curl hides protocol
differences from users HTTP/3 is experimental in curl HTTP/3 is only for HTTPS, there is no
clear text version with --http3 you can ask curl to attempt HTTP/3 --http3 races HTTP/3 against
HTTP/1+2 and picks the winner With HTTP/3, curl can do multiplexed transfers with -Z @bagder
139. @bagder racing curl.se client curl.se has address 151.101.129.91 curl.se has address
151.101.193.91 curl.se has address 151.101.1.91 curl.se has address 151.101.65.91 curl.se has
IPv6 address 2a04:4e42:800::347 curl.se has IPv6 address 2a04:4e42:a00::347 curl.se has IPv6
address 2a04:4e42:c00::347 curl.se has IPv6 address 2a04:4e42:e00::347 curl.se has IPv6 address
2a04:4e42::347 curl.se has IPv6 address 2a04:4e42:200::347 curl.se has IPv6 address
2a04:4e42:400::347 curl.se has IPv6 address 2a04:4e42:600::347 DNS 2a04:4e42:800::347
2a04:4e42:a00::347 2a04:4e42:c00::347 2a04:4e42:e00::347 2a04:4e42::347 2a04:4e42:200::347
2a04:4e42:400::347 2a04:4e42:600::347 151.101.129.91 151.101.193.91 151.101.1.91
151.101.65.91 h2 IPv6 h2 IPv4 h3 IPv4 h3 IPv6
140. HTTP alt-svc server tells client: there is one or more alternatives at "another place"
(possibly using a different HTTP version) The Alt-Svc: response header Each entry has an expiry
time Only recognized over HTTPS curl can save alt-svc alternatives curl can use previously saved
alt-svc alternatives curl --alt-svc altcache.txt https://example.com/ The alt-svc cache is a text based
readable file @bagder
141. HTTP HSTS HSTS - HTTP Strict Transport Security Lets an HTTPS server declare that
clients should automatically interact with this host name using only HTTPS going forward The
Strict-Transport-Security: response header Only recognized over HTTPS Each entry has an expiry
time curl can save HSTS data curl can use previously saved HSTS data curl --hsts hsts.txt
http://example.com/ The HSTS cache is a text based readable file @bagder
142. FTP @bagder slide 142 of 154
143. FTP(S) is not SFTP They are two completely different protocols, both supported by curl
@bagder
144. FTP uses two connections With FTP, a second connection is setup for the data transfer This
second connection adds complications for firewalls and more The 2nd connection is server-to-
client (active) or client-to-server (passive) Passive is default (--ftp‐pasv) Enable active mode with
--ftp‐port (-P) @bagder ftp://curl.se client control connection passive active
145. FTP authentication by default: user: anonymous password: ftp@example.com -u
user:password @bagder
146. FTP directory listing FTP can list the contents of a remote directory curl does not know
what is a directory or not tell curl with a trailing slash curl ftp://example.com/pub/linux/ The list
format is not standardized 🙁 show only file names with --list-only (-l) curl --list-only
ftp://example.com/pub/linux/ @bagder
147. FTP upload curl -T is for upload normally requires -u to be allowed curl -T localfile
ftp://example.com/pub/linux/newfilename curl -T localfile ftp://example.com/pub/linux/ append to
remote file curl --append -T localfile ftp://example.com/pub/linux/ Create dir on the server if
missing: curl --ftp-create-dirs -T localfile ftp://example.com/pub/linux/ @bagder
148. FTPS is FTP with TLS add --ssl-reqd to the command line, keep ftp:// in the URL use
FTPS:// if using (rare) implicit TLS FTPS is even more problematic for stateful firewalls @bagder
149. Future @bagder slide 149 of 154
150. How to dig deeper curl is the accumulated results and experiences from 25 years of
improvements man curl Everything curl source code ask the community! @bagder
151. https://everything.curl.dev/ @bagder
152. Going next? curl is 25 years old curl has been growing and developed its entire lifetime curl
development speed is increasing the Internet does not stop or slow down protocols and new ways
of doing Internet transfers keep popping up new versions, new systems, new concepts and new
ideas keep coming there is now slowdown in sight reasonably, curl will keep develop curl will
keep expanding, get new features, get taught new things we, the community, make it do what we
think it should do you can affect what’s next for curl @bagder
153. @bagder @bagder You can help!
154. Daniel Stenberg @bagder@mastodon.social https://daniel.haxx.se/ Thank you!
Questions? @bagder
AboutSupportTermsPrivacyCopyrightCookie PreferencesDo not sell or share my personal
informationEverand
English