Exercise: Looking at a Real HTTP Response

In this lesson, we'll look at and study real HTTP responses via cURL.

cURL

Run the following command to look at a real HTTP response.

Press + to interact
curl http://example.org --head -silent

cURL (pronounced ‘curl’) is a command-line tool that transfers data to or from a server. The transfer can be based on a vast set of protocols, so we’ll be seeing cURL a lot. It’s perfect for our purposes because it doesn’t require live user interaction. cURL stands for “Client URL.” You can read more about cURL on its manpage.

Explanation

Let’s learn about all of its components.

  • curl is the name of the command that tells the terminal that this is a curl command.
  • The --head flag or -I in short, tells cURL to send an HTTP request with the head method. In other words, the entity-body of the HTTP message is not fetched.
  • The -silent flag tells cURL to not display the progress meter. The progress meter is interpreted as an error on our platform, which is why we decided to remove it. The command is perfectly fine without this flag otherwise.

We encourage you to explore the cURL command. You can find a list of all the flags under the ‘options’ heading on cURL’s manpage. Try different websites and different flags and see what you get!

Sample Output

The output of this command is an HTTP response such as the following. Notice the HTTP response code and the headers.

HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 23 Sep 2019 06:48:39 GMT
Etag: "1541025663"
Expires: Mon, 30 Sep 2019 06:48:39 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (ord/5726)
X-Cache: HIT
Content-Length: 606

Quick Quiz!

1

What is cURL?

A)

A tool that diverts http responses by making them ‘curl’

B)

A command line tool that copies URLs

C)

A command line tool for transferring data based on various protocols

Question 1 of 20 attempted

In the next lesson, let’s have a look at one of the key concepts of computer networks – cookies!

Get hands-on with 1400+ tech skills courses.