美文网首页
GET vs. POST

GET vs. POST

作者: NoteCode | 来源:发表于2016-07-20 15:28 被阅读22次

工作中,最常用的两个HTTP的Method:GET、POST。用大白话说,GET用于“获取”数据(即“读”),POST用于“提交”数据(即“写”)。当然,这样的区别仅是就“用途”方面,也是“软”规则(实际上如果Server端实现比较“二”的话,GET方法也可能有“改变数据”的操作)。

从“协议”角度(浏览器等的实现)来说(即“硬”规则),二者的主要区别有:

  • GET请求所带数据只能放在URL中,而POST的则可以放在Request Body中 [关键区别]
  • GET请求所带数据长度有限制,POST无限制

因此,有几个常见的迷惑就有答案了:

  1. 上传图片,只能用POST(把图片数据写在URL中?一般人不这么干)
  2. jsonp不支持POST方法 (jsonp本就是GET方法实现的,还怎么POST咧? more...

GET

The GET method requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.) The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations."

POST

The POST method requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI. The data POSTed might be, for example, an annotation for existing resources; a message for a bulletin board, newsgroup, mailing list, or comment thread; a block of data that is the result of submitting a web form to a data-handling process; or an item to add to a database.

ref:

  1. wiki
  2. StackOverflow

相关文章

  • AJAX

    GET vs. POST GET请求应该只是读操作,POST才应该是对服务端写操作 数据类型Data Type t...

  • GET vs. POST

    工作中,最常用的两个HTTP的Method:GET、POST。用大白话说,GET用于“获取”数据(即“读”),PO...

  • iOS请求方法和网络安全

    GET和POST请求 GET和POST请求简介 GET请求模拟登陆 POST请求模拟登陆 GET和POST的对比 ...

  • iOS请求方法和网络安全

    GET和POST请求GET和POST请求简介GET请求模拟登陆POST请求模拟登陆GET和POST的对比保存用户信...

  • HTTP 协议

    GET vs POST The Definitive Guide to GET vs POST

  • HTTP

    get和post请求的区别 GET参数通过URL传递,POST放在Request body中。GET比POST更不...

  • Django 学习笔记 - Web基础

    web_basic POST vs GET POST 用于写操作,GET只用于查询POST参数不限长度,GET受限...

  • *Post/Redirect/Get(PRG) pattern

    PRG -> Post/Redirect/Get Post/Redirect/Get (PRG) is a web...

  • 4-ajax流程-open方法和表单

    表单: 数据的提交 get post get, post open方法

  • Fetch/axios

    GET: POST请求 DELETE: AxiosDELETE:删除 POST 增加 GET: 查询

网友评论

      本文标题:GET vs. POST

      本文链接:https://www.haomeiwen.com/subject/hdmvjttx.html