How To: Use Telnet to send a GET and HEAD HTTP request

How To: Use Telnet to send a GET and HEAD HTTP request

This guide goes over how telnet can be used to send both GET and HEAD http requests. These commands can be useful when debugging a website for example finding out whether it supports caching or if the content is being encoded by gzip.

 

Step 1:

Before we are able to enter any telnet commands we first need to start a telnet session by starting it in a terminal.
Command:telnet
Entering the telnet command

Step 2:

Now that we started telnet we are now able to pass a command in order to connect.
Command:o example.com 80
In the command above replace example.com with the website that you would like to connect to.
Response code / message: Trying #.#.#.#… > connected to example.com
HEAD response

Step 3:

As we are now connected to the web server we can start passing commands to it. In this example the two commands that will be used are:

  • HEAD – The HEAD request type only returns the header information and not the actual body of the webpage. This command is useful when you are not interested in returning the body of the page.
  • GET – In contrast to the last command GET return both the head as well as the body.

Other requests types can also be made, for more information visit the specification page. The first command set is a HEAD request.
Command:  ‘HEAD /index.html HTTP/1.1
Command:Host: example.com
After entering the second command press enter / return again.
Response code / message: HTTP/1.1 200 OK
HEAD response

The other command set that can be run is GET which is similar to the last.

Command:  ‘GET /index.html HTTP/1.1
Command:Host: example.com
After entering the second command press enter / return again.
Response code / message: HTTP/1.1 200 OK
GET response

 

Full Transaction

HEAD

Full HEAD transaction

GET

Full GET transaction