Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 350
user1460819 Avatar asked May 17 '13 23:05

user1460819


1 Answers

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.

like image 126
Ansgar Wiechers Avatar answered Sep 27 '22 18:09

Ansgar Wiechers