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条)

报告相同问题?

悬赏问题

  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?