Julia Evans | Link
Recently I’ve been interested in how people learn things. I was reading Kathy Sierra’s great book Badass: Making Users Awesome. It talks about the idea of deliberate practice.
The idea is that you find a small micro-skill that can be learned in maybe 3 sessions of 45 minutes, and focus on learning that micro-skill. So, as an exercise, I was trying to think of a computer skill that I thought could be learned in 3 45-minute sessions.
I thought that making HTTP requests with curl might be a
skill like that, so here are some curl exercises as an experiment!
curl?curl is a command line tool for making HTTP requests. I
like it because it’s an easy way to test that servers or APIs are doing
what I think, but it’s a little confusing at first!
curl $address - perform GET request to $address-i - show response headers-I - only show response headers-X POST - send POST request. Can be replaced with PUT
or DELETE-H - set headers to send with request
e.g. curl $address -H "Accept-Encoding: gzip-v, -vv - verbose mode-k - insecure, don’t verify security
settings/certificates--cert, --key - use a client certificate--data, -d - send a POST request with data
e.g. curl $address -d '{ "name" : "king' }' or
curl $address @file.json. The send option will send a file
which is handy if the data is quite large.copy as curl - in some developers tools this option is
presented allowing one to download from the command line.These exercises are about understanding how to make different kinds of HTTP requests with curl. They’re a little repetitive on purpose. They exercise basically everything I do with curl.
To keep it simple, we’re going to make a lot of our requests to the same website: https://httpbin.org. httpbin is a service that accepts HTTP requests and then tells you what request you made.
value=panda).User-Agent: elephant.{"value": "panda"}Content-Type header to application/json
(because POST requests need to have a content type that matches their
body). Look at the json field in the response to see the difference from
the previous one.Accept-Encoding: gzip (what happens? why?)Accept: image/png. Save the output to a PNG file and open
the file in an image viewer. Try the same thing with with different
Accept: headers.panda: elephant)-u username:password)Accept-Language: es-ES header.