如果有效负载很大,则休息 POST VS GET [英] Rest POST VS GET if payload is huge

查看:49
本文介绍了如果有效负载很大,则休息 POST VS GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我理解 GET 和 POST 的定义如下.

I understand the definition of GET and POST as below.

GET:列出集合的成员,并附上他们的成员 URI,以便进一步导航.例如,列出所有待售汽车.

GET: List the members of the collection, complete with their member URIs for further navigation. For example, list all the cars for sale.

POST:在集合中创建一个新条目,其中 ID 由集合自动分配.创建的 ID 通常包含在此操作返回的数据中.

POST: Create a new entry in the collection where the ID is assigned automatically by the collection. The ID created is usually included as part of the data returned by this operation.

我的 API 在服务器中搜索一些细节,其中包含带有 JSON 消息的巨大请求负载,在这种情况下我应该使用哪个动词?

MY API searches for some detail in server with huge request payload with JSON Message in that case Which Verb should i use ?

还有谁能告诉我可以在查询字符串中传递的字符的长度.

Also can anyone please let me know the length of the characters that can be passed in query string.

推荐答案

GET 和 POST 请求的主要区别在于,在前者中,整个请求被编码为 URL 本身的一部分,而在后者中,参数在标头之后发送.此外,在 GET 请求中,不同的浏览器会对 URL 的大小施加不同的限制.大多数现代浏览器至少允许 200KB,但 Internet Explorer 似乎将 URL 大小限制为 2KB.

The main difference between a GET and POST request is that in the former, the entire request is encoded as part of the URL itself, whereas in the latter, parameters are sent after the header. In addition, in GET request, different browsers will impose different limits on how big the URL can be. Most modern browsers will allow at least 200KB, however Internet Explorer seems to limit the URL size to 2KB.

话虽如此,如果您怀疑您将传入大量参数,这些参数可能会超过接收 Web 服务器对 GET 请求施加的限制,您应该改用 POST.

That being said, if you have any suspicion that you will be passing in a large number of parameters which could exceed the limit imposed on GET requests by the receiving web server, you should switch to POST instead.

这是一个调查 GET 行为的网站大多数现代浏览器,值得一读.

Here is a site which surveyed the GET behavior of most modern browsers, and it is worth a read.

这篇关于如果有效负载很大,则休息 POST VS GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆