Two commonly used methods for a request-response between a client and server are: GET and POST.

  • GET - Requests data from a specified resource
  • POST - Submits data to be processed to a specified resource

The GET Method

Note that query strings (name/value pairs) is sent in the URL of a GET request:

/test/demo_form.asp?name1=value1&name2=value2

Some other notes on GET requests:

  • GET requests can be cached/GET请求可以被缓存
  • GET requests remain in the browser history/GET请求保存在浏览器历史中
  • GET requests can be bookmarked/GET请求可以被保存为书签
  • GET requests should never be used when dealing with sensitive data/GET请求不能用来处理敏感数据
  • GET requests have length restrictions/GET请求有数据长度限制
  • GET requests should be used only to  data/GET请求应该被用来获取数据

The POST Method

Note that query strings (name/value pairs) is sent in the HTTP message body of a POST request:

POST /test/demo_form.asp HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2

Some other notes on POST requests:

  • POST requests are never cached/POST请求不会被缓存
  • POST requests do not remain in the browser history/POST请求不会保存在浏览器历史中
  • POST requests cannot be bookmarked/POST请求不能被存为标签
  • POST requests have no restrictions on data length/POST请求没有数据长度限制

Compare GET vs. POST

The following table compares the two HTTP methods: GET and POST.

  GET POST
BACK button/Reload Harmless Data will be re-submitted (the browser should alert the user that the data are about to be re-submitted)
Bookmarked Can be bookmarked Cannot be bookmarked
Cached Can be cached Not cached
Encoding type application/x-www-form-urlencoded application/x-www-form-urlencoded or multipart/form-data. Use multipart encoding for binary data
History Parameters remain in browser history Parameters are not saved in browser history
Restrictions on data length Yes, when sending data, the GET method adds the data to the URL; and the length of a URL is limited (maximum URL length is 2048 characters) No restrictions
Restrictions on data type Only ASCII characters allowed No restrictions. Binary data is also allowed
Security GET is less secure compared to POST because data sent is part of the URL

Never use GET when sending passwords or other sensitive information!

POST is a little safer than GET because the parameters are not stored in browser history or in web server logs
Visibility Data is visible to everyone in the URL Data is not displayed in the URL

源地址:http://www.w3schools.com/tags/ref_httpmethods.asp

HTTP Methods: GET vs. POST的更多相关文章

  1. How to implement equals() and hashCode() methods in Java[reproduced]

    Part I:equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and ...

  2. Sort Methods

    heyheyhey ~~ It has been a long time since i come here again...whatever today i will summerize some ...

  3. Top 10 Methods for Java Arrays

    作者:X Wang 出处:http://www.programcreek.com/2013/09/top-10-methods-for-java-arrays/ 转载文章,转载请注明作者和出处 The ...

  4. Don’t Use Accessor Methods in Initializer Methods and dealloc 【初始化和dealloc方法中不要调用属性的存取方法,而要直接调用 _实例变量】

    1.问题:    在dealloc方法中使用[self.xxx release]和[xxx release]的区别? 用Xcode的Analyze分析我的Project,会列出一堆如下的提示:Inco ...

  5. C# Extension Methods

    In C#, extension methods enable you to add methods to existing class without creating a new derived ...

  6. CLR via C# 3rd - 08 - Methods

       Kinds of methods        Constructors      Type constructors      Overload operators      Type con ...

  7. 转 Dynamics CRM Alert and Notification JavaScript Methods

    http://www.powerobjects.com/2015/09/23/dynamics-crm-alert-and-notification-javascript-methods/ Befor ...

  8. AX7: HOW TO USE CLASS EXTENSION METHODS

    AX7: HOW TO USE CLASS EXTENSION METHODS   To create new methods on a standard AX class without custo ...

  9. Keeping Async Methods Alive

    Consider a type that will print out a message when it’s finalized, and that has a Dispose method whi ...

  10. 增强学习(四) ----- 蒙特卡罗方法(Monte Carlo Methods)

    1. 蒙特卡罗方法的基本思想 蒙特卡罗方法又叫统计模拟方法,它使用随机数(或伪随机数)来解决计算的问题,是一类重要的数值计算方法.该方法的名字来源于世界著名的赌城蒙特卡罗,而蒙特卡罗方法正是以概率为基 ...

随机推荐

  1. Oracle DB 使用RMAN将数据库移植到ASM存储区

    1. 完全关闭数据库. 2. 关闭数据库并修改服务器参数文件,以使用Oracle Managed Files (OMF). 3. 编辑并执行以下RMAN 脚本: STARTUP NOMOUNT; RE ...

  2. mysql lock

    http://blog.chinaunix.net/uid-21505614-id-289450.html http://bbs.csdn.net/topics/340127237 http://ww ...

  3. VirtualBox AndroidX86 网络设置

    在Virtualbox中,把虚拟机网络设为“网络地址转换(NAT)”模式,高级中控制芯片(T)选择:PCnet-FAST III(Am79C973), 然后启动你的android-x86 4.0虚拟机 ...

  4. Godaddy域名因为whois信息虚假被暂时关闭

    如果你收到来自 Godadddy 通过 invalidwhois@godaddy.com 发出的标题为如下内容的邮件: [Incident ID: xxxx] xxxx - DS Invalid Wh ...

  5. MySQL临时表的简单用法(复制)

      当工作在非常大的表上时,你可能偶尔需要运行很多查询获得一个大量数据的小的子集,不是对整个表运行这些查询,而是让MySQL每次找出所需的少数记录,将记录选择到一个临时表可能更快些,然后在这些表运行查 ...

  6. 记一次服务器迁移SVN客户端更换IP

    服务器迁移,SVN服务端IP由原10.58.8.231更换至10.58.1.230   TortoiseSVN更换ip地址操作如下: 打开svn项目的根目录,右键如图操作: 修改ip地址为10.58. ...

  7. PV、TPS、QPS是怎么计算出来的?

    PV=page viewTPS=transactions per secondQPS=queries per secondRPS=requests per second RPS=并发数/平均响应时间 ...

  8. java内存回收

    java中引用类型 强引用 Persnon  p = new Person(); 当指向Person对象的引用计数为0时,Person对象才能被垃圾回收器回收. 软引用 SoftReference&l ...

  9. JVM调优总结(转)

    本文转自:http://my.oschina.net/xishuixixia/blog/132395 常用的调优参数. 1.堆大小 -Xms和-Xmx用于指定堆大小,我们需要将他们俩设置为一样的值,以 ...

  10. java线程方面的知识

    java中单继承,多实现的: 若为多继承,那么当多个父类中有重复的属性或者方法时,子类的调用结果会含糊不清,因此用了单继承. 为什么是多实现呢? 通过实现接口拓展了类的功能,若实现的多个接口中有重复的 ...