apache“实时”加载cgi

发布于 2024-12-28 00:41:20 字数 320 浏览 2 评论 0原文

我在 mamp apache 服务器上使用一台 cgi 服务器。 当我加载一个脚本时,例如:

echo "asd" 睡10 回声“dsa” sleep 20

我需要等待 30 秒才能看到回声。它不会每行进行渲染,似乎需要完全加载脚本才能将数据发回。

如何配置 apache 返回该行,然后等待 10 秒,打印另一行,然后等待?

在 php 上,如果你这样做,脚本将打印然后休眠,但我的 bash 脚本不会在 cgi 上这样做。

如果我用 bash script.cgi 运行它,它会打印行、等待、打印和等待。所以这似乎是apache的问题之一。

I'm using one cgi server on the mamp apache's server.
When I load one script like:

echo "asd"
sleep 10
echo "dsa"
sleep 20

I need to wait 30 seconds to see the echo. It doesn't do the render per line, it seems it needs the script to load entirely to send the data back.

How can I configure to the apache returns the line, then wait the 10 secconds, print the another line and then wait?

On php if you do that the script will print and then sleep, but my bash script doesn't do that on the cgi.

If I run it with bash script.cgi it prints the line, wait, print and the wait. So it seems to be one problem with the apache.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情换悲伤 2025-01-04 00:41:21

这是浏览器的缓冲。

Apache 不缓冲 cgi-bin 脚本。它将立即将该行发送到浏览器。
在 apache / 脚本方面无事可做。
可能有一些非标准 HTTP 标头您可以附加到响应中以强制浏览器提前显示该页面,但我不知道是哪一个。

It's the browser's buffering.

Apache does not buffer cgi-bin scripts. It sends the line immediately to the browser.
Nothing to do on apache / script side.
May be there are some non standard HTTP header you can attach to the response to force the browser to early display the piece of page, but I don't know which.

云朵有点甜 2025-01-04 00:41:21

我发现 Firefox 和 Chromium 缓冲区大约有 1 KB,可以启发式地确定输出是文本还是二进制。对于纯文本,您可以输出尽可能多的空格,或者对于 HTML,创建足够大的注释。之后就可以逐步显示内容了。

在我的测试中,常规 CGI 脚本不起作用,因为 Apache 进行了缓冲以对输出进行 gzip 压缩(我使用了 Wireshark)。相反,我编写了一个无解析标头 (NPH) 脚本来自行处理分块传输编码。

I found that Firefox and Chromium buffer about 1 kilobyte to heuristically determine if the output is text or binary. For plain text you can output as many spaces, or for HTML create a sufficiently large comment. After this, content can be progressively displayed.

In my tests, a regular CGI script did not work since Apache buffered in order to gzip the output (I used Wireshark). Instead, I wrote a No Parsed Headers (NPH) script that handled chunked transfer encoding on its own.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文