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. php的soap无故出错的真凶:wsdl缓存

    soap不更新的真凶: 当我修改了服务端的调用方法后,更新了wsdl,客户端的参数老是丢失(不是全丢失,而是部分),让人很郁闷. 第二天我索性增加了一个服务端的新方法,更新了wsdl,但是客户端请求却 ...

  2. Hibernate错误:Could not bind factory to JNDI

    使用hibernate时,将hibernate.cfg.xml中 <session-factory name="SessionFactory">的那么属性去掉即可.因为 ...

  3. 用tophat和cufflinks分析RNAseq数据[转载]

    转自:http://blog.sciencenet.cn/home.php?mod=space&uid=635619&do=blog&id=884213 //今天看到一篇非常好 ...

  4. Spring基本功能-扫描与继承

    一.Spring的扫描 一个稍大的项目中,可能会有成百上千个bean,此时采用xml的配置形式注入bean,一方面是配置文件显得十分庞大,另一方面也会导致后期的维护难度增加,为 此,Spring引入了 ...

  5. c++中字符串反转的3种方法

    第一种:使用algorithm中的reverse函数 #include <iostream> #include <string> #include <algorithm& ...

  6. [golang note] 错误处理

    错误处理 • 错误处理的标准模式 √ golang错误处理的标准模式:error接口. √ golang函数如果要返回错误,规范上是将error作为多返回值中的最后一个,但这并非是强制要求. ▶ er ...

  7. MFC中存在的不属于任何类的全局函数,它们统统在函数名称开头加上Afx

    MFC中存在的不属于任何类的全局函数,它们统统在函数名称开头加上Afx. 函数名称 说明 AfxWinInit 被WinMain(MFC提供)调用的一个函数,用做MFC GUI程序初始化的一部分,如果 ...

  8. 深入理解JS对象和原型链

    函数在整个js中是最复杂也是最重要的知识 一个函数中存在多面性: 1.它本身就是一个普通的函数,执行的时候形成的私有作用域(闭包),形参赋值,预解释,代码执行,执行完 成后栈内存销毁/不销毁. 2.& ...

  9. 一步一步学EF系列三【数据迁移】

    我们每篇的内容都不多,所以希望在学习的过程中最后能亲自敲一下代码 这样更有利于掌握. 我们现在接着上篇的例子,我们现在给随便的表增加一个字段 CreateTime 创建日期 运行一下 看看会怎么样 修 ...

  10. 斐迅面试记录—SSL和TLS的区别

    SSL 是洋文“Secure Sockets Layer”的缩写,中文叫做“安全套接层”.它是在上世纪90年代中期,由网景公司设计的.(顺便插一句,网景公司不光发明了 SSL,还发明了很多 Web 的 ...