Delphi - indy 发送 post 同时使用多个 IdHTTP

Delphi - indy send post using multiple IdHTTP in the same time

如何使用 TIdHTTP 同时发送多个 post 请求?

lHTTP1.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);
lHTTP2.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);
lHTTP3.Post('http://'+cURL+'/build.php?',lParamList, ResponseContent);

我尝试使用三个线程来做到这一点,但每条 post 消息之间有一秒的延迟。

如何在同一秒内发送所有 post 条消息?

由于TIdHTTP是一个阻塞组件,使用单独的线程是正确的做法。每个 post 上的 1s 延迟可能与 OS 调度线程的方式有关,或者可能与网络延迟有关,或者您可能正在使用具有内部延迟的 Indy 版本(例如,如果 HTTP 服务器向 POST 请求发送 3xx 响应,TIdHTTP 最多等待 5 秒以确保服务器发送正确的响应正文 - 一些错误的服务器不会)。很难知道你的 1s 延迟实际发生在哪里。您必须 debug/profile 您的项目才能找到答案,我们无法为您做到这一点。