如何在 TIdHTTPServer 中实现 ajax 进度?

How do I implement ajax progress in TIdHTTPServer?

我有一个服务项目,它通过 TIdHTTPServer 和一个 Web 前端提供一个 HTTP 服务器。用户可能启动的许多功能可能需要 5-10 秒才能完成,在此期间他们只能看到 gif 动画,而 ajax 请求等待我的 delphi 代码完成并且 return一个状态。

我想实现进度条或百分比(可能是估计的剩余时间等),但我不确定应该如何实现。 XMLHTTPRequest() 有一个进度事件,这似乎很容易在客户端实现,但我如何让服务器响应它的进度?

来自 Ajaxpatterns.org

Another way to deal with long XMLHttpRequest Calls is to explicitly introduce a second monitoring channel. While the primary request takes place, a sequence of monitoring requests are issued to ask the server for a progress estimates. For example, the server might be looping through 1000 records, running a transformation on each of those and saving it to the database. The loop variable can be exposed so that a monitoring service can convert it into a percentage remaining figure.