Thursday, October 30, 2008

How to Telnet to a Web Server - HTTP Requests through Telnet

A web server, responding to a HTTP GET request sends the required content to the client. Normally we don't see what is sent between the web client and the server. However we can easily see what is sent by the server by telneting to that web server.

To connect to the web server - open a command line and type the command
telnet host port
eg. telnet www.wso2.com 80

Then you'll get connected to the particular web server and then you can enter any HTTP command you want such as GET, HEAD.

If you need to request for a web page from the web server you can type the HTTP request as follows.

GET pageName HTTP/1.0
eg. GET /products HTTP/1.0

Hit enter twice. Then you will get a response (if page exists)as follows.

HTTP/1.0 200 OK
Date: Thu, 30 Oct 2008 18:17:16 GMT
Server: Apache/2.2.9
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=5322082bf473207961031e3df1f45a22; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Pingback: http://wso2.com/xmlrpc.php
Connection: close
Content-Type: text/html; charset=UTF-8

content goes here

.
.
.


You'll get a 404 status if page not found, 301 if the page is moved permanently and 401 if you are not authorized to access the page. More HTTP status codes can be found here.

You can follow a similar way to issue other HTTP commands with the relevant content.

9 comments:

ශාකුන්තල | Shaakunthala said...

telnet kalanir.blogspot.com 80
GET / HTTP/1.0

doesn't work.... what to do?

Coz that's HTTP 1.1... virtual hosting.. ;-)

just,
GET / HTTP/1.1
Host: kalanir.blogspot.com

And,... bingo!


Anyway,... this telnet thing is a great thing that can sometimes find 'secrets'. :-)

Gediminas said...

You can look to http://sourceforge.net/projects/wwwposter/ for working example

kalani Ruwanpathirana said...

Oh..thanks Shakunthala..

IHG said...

can you tell me if website use post command then how can get server detail using telnet???

Unknown said...



Great Post about Server support. I can see that you will be a professional Man By this site.
We have also arranged a service.
Our Emergency Exchange SupportTeam provides emergency support and assistance.
Our Exchange Server experts can log on remotely to diagnose and fix just about any problem you may be experiencing,
24×7. Today’s advanced remote desktop tools, which are included with Microsoft Windows Server OS,
allow us to rapidly support Microsoft Exchange just as if we were at your place of business.



Unknown said...
This comment has been removed by the author.
Unknown said...

Internet service is too much involved in our best essay writing service that is quite different and against of our expectations. Now we can enjoy 4G internet service that help us in internet surfing in very nice speed.

Robert said...

What should you look for in a good W3 partner? What should you expect from the web hosting company you choose? A lot and plenty of it.
Weebly Email Hosting

Unknown said...

I haven't tried Telnet yet. And I will have time to try this soon because I find this very interesting. Please also visit superior essay for writing services as this will be of great help for your paper works.

Related Posts with Thumbnails