GET和POST方法之间的区别

Http protocol supports the following methods to retrieve data such as get, post, put, delete etc. In this article, I will tell you about the difference between GET and POST methods.

Http协议支持以下方法来检索数据,例如get,post,put,delete等。在本文中,我将向您介绍GET和POST方法之间的区别。

These methods are basically used to get and send any data. Because of these methods, the request-response between server and client exist. To send data streams we use these two methods. GET and POST are the most common HTTP methods.

这些方法基本上用于获取和发送任何数据。 由于这些方法,服务器和客户端之间存在请求-响应。 要发送数据流,我们使用这两种方法。 GET和POST是最常见的HTTP方法。

GET和POST方法之间的区别 (Difference between GET and POST Method)

Difference between GET and POST Method

Image Source

图片来源

GETPOST
We add parameters in URL and get data in response.Send additional data from the client or browser to the server.
Sends data as part of URI (uniform resource identifier)Sends data as HTTP content.
get return same results every time.The post method implements in that way it changes with every request.
We can send limited data in the header.We can send a large amount of data because its part of the request body.
It is not much secure because data is exposed to URL and we can easily bookmark it and send it.It  is more secure because data is passed in the request body and user not able to bookmark it
You can cache the data.You cannot cache post request data.
GET is bounded by the max. URL length continued by the browser and web server.POST doesn’t have such conditions.
GET is used to request data from a particular resource.POST is used to send info to a server to create/update a resource.
parameters passed  in URLparameters passed in body
This is not happening in get method.Use POST for destructive things such as creation, editing, and deletion.
get is used for fetching documents.post used for updating data.
in get we pass things like customer id, uId to get a response.post request sends information to server like customer info, file upload etc.
得到 开机自检
我们在URL中添加参数并获取数据作为响应。 从客户端或浏览器向服务器发送其他数据。
将数据作为URI(统一资源标识符)的一部分发送 将数据作为HTTP内容发送。
每次都返回相同的结果。 post方法以这种方式实现,它随每个请求而变化。
我们可以在标头中发送有限的数据。 因为它是请求主体的一部分,所以我们可以发送大量数据。
它不是很安全,因为数据公开给URL,我们可以轻松地为其添加书签并发送。 由于数据在请求正文中传递并且用户无法为其添加书签,因此它更加安全
您可以缓存数据。 您不能缓存发布请求数据。
GET受最大值限制。 URL长度由浏览器和Web服务器继续。 POST没有这样的条件。
GET用于从特定资源请求数据。 POST用于将信息发送到服务器以创建/更新资源。
URL中传递的参数 体内传递的参数
在get方法中不会发生这种情况。 使用POST进行破坏性操作,例如创建,编辑和删除。
get用于获取文档。 用于更新数据的帖子。
在获取过程中,我们传递客户ID,uId之类的信息以获取响应。 发布请求将信息发送到服务器,例如客户信息,文件上传等。

Check out the example of both requests.

查看两个请求的示例。

GET Request:

GET请求:

GET https://api.github.com/users/{name}

获取https://api.github.com/users/{name}

Here you can pass name according to that you will get data.

在这里您可以根据您将获得数据的名称进行传递。

GET https://api.github.com/users/seeschweiler

GET https://api.github.com/users/seeschweiler

POST Request:

POST请求:

In this you will have to send content-type such as multipart/form-data, application/json,  application/x-www-form-urlencoded and object or data that you have to pass in body.

在这种情况下,您将必须发送内容类型,例如multipart / form-data,application / json,application / x-www-form-urlencoded以及您必须在正文中传递的对象或数据。

Host: foobar.example

主持人:foobar.example

Content-Type: application/json

内容类型:application / json

Object- [{name1:value1},{name2:value2}]

对象-[{name1:value1},{name2:value2}]

In this you are posting JSON data to API.

在此,您将JSON数据发布到API。

Comment down below if you have any queries related to get vs post methods.

如果您有任何与get vs post方法相关的查询,请在下面注释掉。

翻译自: https://www.thecrazyprogrammer.com/2019/11/difference-between-get-and-post-method.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值