1

I learned you could use telnet to download a webpage(making http request), like

telnet www.example.com 80
GET HTTP / HTTP/1.1
HOST: www.example.com

then the output would be an html source page or something.

My question is if we had specified www.example.com when initializing the telnet request in

telnet www.example.com 80

why do we still need to specify that again in

HOST: www.example.com

?

Thanks guys!

Hang
  • 113
  • 2

1 Answers1

4

telnet has no understanding of HTTP, so all telnet example.com 80 does is open a connection to example.com on port 80. The subsequent HTTP request is entirely up to you, and that includes the headers.

Without the Host header, your request will go to the default virtualhost on the server handling example.com (as if you'd typed in the IP address of the server in a browser), which may not be example.com.

ceejayoz
  • 32,910
  • 7
  • 82
  • 106