|
|
HTTP Client Methods - GET and POSTThere are three commonly used HTTP methods
The GET methodThe GET method is used to retrieve HTML documents from the server. It is a part of the request line from the client and tells the server to pass a copy of the document back to the browser or run a CGI program. GET is also used to send user information from an HTML form. Through this, the data is sent as a part of the URL in 'name-value' pairs. <FORM NAME="myform" ACTION="cgi-bin/validate.cgi" METHOD="GET"> First Name: <INPUT TYPE="TEXT" NAME="fname" SIZE="20"><BR> Last Name: <INPUT TYPE="TEXT" NAME="lname" SIZE="20"> <BR> <INPUT TYPE="SUBMIT" VALUE="SUBMIT"> </FORM> And this will be displayed in the browser as: Now, let us suppose your name is John Doe. When you submit this form, the data is attached to the URL in name-value pairs. Each name-value pair is demarcated by a '&' sign and the data is separated from the actual URL with a '?' sign. Thus after submission the URL in the address/location bar of the browser will be as: www.sitename/cgi-bin/validate.cgi?fname=John&lname=Doe Note how the ? and & sign separate the URL from the data and the name-value pairs, respectively. You can also call CGI programs by supplying data with the URL in an HTML link like: <A HREF="http://www.somesite.com/cgi-program.cgi?name1 =value1&name2=value2>Link to somesite</A> which shows up as: If you move your mouse over this link, you will be able to see the URL and the attached data in the status bar of your browser. The Post MethodData from the POST method is sent by the client as a part of the request body. The server receives this data and sends it to a CGI program along with other variables. The METHOD attribute inside the <FORM> tag will carry POST as its value. The big advantage in using POST over GET is that the data is not open to prying eyes. Also, via GET, you can transfer only a limited amount of data; POST exerts no such limitations. The Head METHODThis method is used to find information about a document located on the server not retrieve it. It is very similar to the GET method except no data is returned by the server.
Page contents: A brief on HTTP client methods especially GET and POST and how they are used to transfer files and web pages over the web.
Page URL: http://www.webdevelopersnotes.com/basics/ http_client_methods_get_post.php3
|
|