HTTP Methods: GET vs. POST

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

时间: 2024-11-03 17:31:29

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

浅析Ruby中的methods,private_methods和instance_methods

首先,methods,private_methods是Object类的实例方法;instance_methods是Module类的实例方法. 我们先来看看这样安排的原因: 我们知道一个Ruby对象所能调用的方法包含在其祖先链中(包含这个对象的单例类).这里所说的Ruby对象可以分为2类,一类是普通对象,像"abc",2,obj=Object.new这种对象,它们所属的类分别是String,Fixnum,Object,我们称这种对象为普通对象:还有一类对象是类(类本身也是一种对象),像S

Spring MVC @RequestMapping Annotation Example with Controller, Methods, Headers, Params, @RequestPar

Spring MVC @RequestMapping Annotation Example with Controller, Methods, Headers, Params, @RequestParam, @PathVariable Pankaj July 4, 2014 Spring @RequestMapping is one of the most widely used Spring MVC annotation.org.springframework.web.bind.annotat

methods 方法选项

最简单的使用方法,一个数字,每点击一下按钮加1 html <div id="app"> <span v-text="number"></span> <button @click="add()">add</button> </div> js var vm = new Vue({ el:"#app", data:{ number:1 }, methods:{

Allow Pin Swapping Using these Methods options

Frm:http://techdocs.altium.com/display/ADOH/Pin,+Pair+and+Part+Swapping#Pin,PairandPartSwapping-SwapManagerDialog Controlling How the Swaps are Performed on the Schematic In the PCB editor pin, pair and part swaps are performed by exchanging nets on

ISL - Ch.5 Resampling Methods

Resampling methods involve repeatedly drawing samples from a training set and refitting a model of interest on each sample in order to obtain additional information about the fitted model. In this chapter, we discuss two of the most commonly used res

Grid (read-only) objects and methods (client-side reference)获取子表单对象的一些方法 Crm 2016

https://msdn.microsoft.com/en-us/library/dn932126.aspx#BKMK_GridControl Updated: November 29, 2016 Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online You can set event handlers to execute scripts whe

[转]Sequence of methods in form and table in AX

转自:http://axvuongbao.blogspot.jp/2013/09/sequence-of-methods-in-form-and-table.html Form: Sequence of Methods calls while opening the Form Form — init () Form — Datasource — init () Form — run () Form — Datasource — execute Query () Form — Datasource

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 transitive). In addition, it must be consistent (if the objects are not modified, then it must keep returning the same value). Furthermore, o.equals(n

jQuery基础教程-第8章-002Adding jQuery object methods

一.Object method context 1.We have seen that adding global functions requires extending the jQuery object with new methods. Adding instance methods is similar, but we instead extend the jQuery.fn object(The jQuery.fn object is an alias to jQuery.proto

Disconnected: No supported authentication methods available (server sent: publickey)

安装Git客户端后,进行PULL时报如下错误 disconnected no supported authentication methods available(server sent: publickey,keyboard interactive)解决方案 因为TortoiseGit和Git的冲突 我们需要把TortoiseGit设置改正如下. 1.找到TortoiseGit -> Settings -> Network 2.将SSH client指向~\Git\usr\bin\ssh.e