POST与GET方法 - 在网络级别,受延迟影响更大? [英] POST vs GET methods - at the network level, which is more impacted by latency?

查看:186
本文介绍了POST与GET方法 - 在网络级别,受延迟影响更大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTTP GET和POST请求的网络通信是否有区别?



使用GET,我明白整个请求都是一次发送的。
对于POST,我认为发送了初始请求,然后发送了第二个请求,它发送了所有参数。

例如,假设等待时间在服务器和客户端之间是500ms。 GET / POST调用的总时间是多少?

解决方案

我在Wireshark中进行监控时测试了这一点。



我创建了一个简单的HTML表单,并在GET和POST之间切换了方法。

一致地,我注意到GET请求发送一个数据包,而POST发送两个。
即使表单数据非常小,POST数据也总是以第二个数据包的形式发送。



这表明POST会受到延迟。

UPDATE 2011.07.05:
$ b 这里是简单的HTML表单对于POST:

 < form method =GETaction =/ form-handler.aspx> 
< input type =hiddenvalue =12345/>
< input type =submitvalue =点击提交/>
< / form>

以下是POST版本:

 < form method =POSTaction =/ form-handler.aspx> 
< input type =hiddenvalue =12345/>
< input type =submitvalue =点击提交/>
< / form>


Is there any difference in network communication for HTTP GET and POST requests?

With GET, I understand that the entire request is sent in one go. With POST, I think the initial request is sent, and then a second request is sent which sends all the parameters.

For example, assume that the latency between server and client is 500ms. What would be the total time for a GET vs POST call?

解决方案

I tested this while monitoring in Wireshark.

I created a simple HTML form and toggled the method between GET and POST.

Consistently, I noticed that GET requests send one packet, while POST sends two. Even when the form data is very small, the POST data is always sent in the second packet.

This suggests to me that POST would be more impacted by latency.

UPDATE 2011.07.05:

Here is the simple HTML form for POST:

<form method="GET" action="/form-handler.aspx">
<input type="hidden" value="12345" />
<input type="submit" value="click to submit" />
</form>

Here is the POST version:

<form method="POST" action="/form-handler.aspx">
<input type="hidden" value="12345" />
<input type="submit" value="click to submit" />
</form>

这篇关于POST与GET方法 - 在网络级别,受延迟影响更大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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