doupu1727 2018-12-19 05:11
浏览 96
已采纳

HTTP中的GET和POST之间的区别[重复]

This question already has an answer here:

There are some posts about the difference between POST and GET, but my problem is more specific, here it is:

I can use GET to send and get data from the server using this VBScript example:

Send "https://www.server.com/send.php"
Sub Send(url)
    Dim objHTTP, MyResponse
    Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
    objHTTP.Open "GET", url, False
    objHTTP.Send "One Plus One"
    MsgBox objHTTP.ResponseText()
End Sub

But this same example works if I change GET with POST, so:

  1. What's the difference?
  2. What should I use when I want to send and receive data at the same time?

And this is my PHP code on the server if you're interested:

<?php
$stdin = fopen('php://input', 'r');

$Data = '';
while (!feof($stdin))
  $Data .= fread($stdin, 8192);

$Data .= " Equals Two";

echo $Data;
?>

Note that I didn't mention HTML, because my code has nothing to do with it, but if the difference has to do with HTML, I would be happy to know about it.

</div>
  • 写回答

2条回答 默认 最新

  • doudang2537 2018-12-19 05:21
    关注

    A POST request has a body, this body carries the information you are trying to send with the request, and the main advantage of POST is that this data can be quite lengthy, you can even send files.

    GET does not have a body, if you want to send any data it has to be carried in the Query String, which is basically the stuff that goes after the ? in the URL. Example:

    https://google.com/?q=this+is+the+data
    

    As the data goes in the URL, you cant really put whatever you want there. Most browsers and servers will limit the maximum URL size to something in the order of a few kilobytes, and it is not very useful at all if you intent to post long texts or files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 ue5运行的通道视频都会有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数