打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
HTTP Client Methods - GET and POST

There are three commonly used HTTP methods

  • GET
  • POST
  • HEAD

The GET method

The GET method is used to retrieve web pages 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 online form on a web page to the server. Through this, the data is sent as a part of the URL in ‘name-value‘ pairs.
The XHTML code code for a simple form would look something like this (XHTMl is simply a slightly more advanced form of HTML):

<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:

First Name:
Last Name:

Note: Submit button does not work here!

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:

Link to somesite

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 Method

Data 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 METHOD

This 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.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CGI简介
面试
C# 客户端篇之实现Restful Client开发(RestSharp帮助类)
json-server----模拟后端接口
GET和POST有什么区别?及为什么网上的多数答案都是错的。[转]
PHP 使用 $_SERVER['PHP_SELF'] 获取当前页面地址及其安全性问题
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服