Sending request to the server Manually

I am going to show how to send information manually using GET and POST methods to a PHP page on my local apache server.

Prerequsites:
1. Locally Running apache server.(Though you can test with any website also say google.com)
2.A PHP script(say test.php) for testing.

test.php

   <?php echo "name=".$_REQUEST['name'].",age=".$_REQUEST['age']; ?>


GET METHOD

   telnet 127.0.0.1 80


Now Type the Request Manually

GET /test.php?name=test&age=20 HTTP/1.0

Press enter twice.
You will see something similar to the following:

HTTP/1.1 200 OK 
Date: Sun, 13 Mar 2011 08:37:25 GMT
Server: Apache/2.2.11 (Unix) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.2.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0  
X-Powered-By: PHP/5.2.9  
Content-Length: 21
Connection: close
Content-Type: text/html
name=test,age=20

The lines 1-7 respresent Response Header & the text on line 9 is the response message that you would have seen on the browser if used.

POST Method

telnet 127.0.0.1 80

Now Type the Request Manually

POST /test.php HTTP/1.0
content-type:application/x-www-form-urlencoded
content-length:17

Now press enter and type the message part.

name=test&age=132

Press enter again.

You will see something similar to the following:

HTTP/1.1 200 OK
Date: Sun, 13 Mar 2011 08:43:02GMT
X-Powered-By: PHP/5.2.9
Content-Length: 22
Connection: close
Content-Type: text/html

name=test,age=132

Again,the text on lines 1-7 is Response Header & the text on line 9 is the response message that you would have seen on the browser if used.

... Loading comments