Can't get the http response using telnet from the command line

user1460819 picture user1460819 · May 18, 2013 · Viewed 18.7k times · Source

I'm using Windows 7 (x64). I want to send an http request from a command line and to get a response. I use Telnet. I type in the command line: telnet www.google.com 80. enter image description here After I press "enter" the screen becomes black (everything disappears from the cmd screen). enter image description here

After a couple of minutes it shows a standard command prompt without outputting anything. enter image description here

When I launch telnet in my command line (typing telnet without parameters) and type o www.google.com 80, it outputs Connecting to www.google.com. After a few minutes it says press any key. After pressing any key it outputs The connection was lost

My question is: how can I actually get an http response? What am doing wrong?

Answer

Ansgar Wiechers picture Ansgar Wiechers · May 18, 2013

The connection is established and waiting for you to enter a command. Type GET / HTTP/1.0 and press Enter twice. The command is case-sensitive. It's not displayed as you type, because localecho is off by default. You can enable localecho like this:

C:\>telnet
Welcome to Microsoft Telnet Client

Escape Character is 'CTRL++'

Microsoft Telnet> set localecho
Local echo on
Microsoft Telnet> open www.example.com 80
Connecting To www.example.com...
GET / HTTP/1.0

Or you could use PuTTY, which displays the typed text by default (you need to configure the session to not close the Window on exit, though).

For more information about HTTP see Wikipedia. For the protocol specification see RFC 2616.