的Apache2和CGI - 如何保持阿帕奇从缓存POST数据? [英] Apache2 and CGI - how to keep Apache from buffering the POST data?

查看:587
本文介绍了的Apache2和CGI - 如何保持阿帕奇从缓存POST数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提供CGI文件上传的实时分析和在屏幕上显示的数据,因为它是被上传。

I'm trying to provide live parsing of a file upload in CGI and show the data on screen as it's being uploaded.

然而,的Apache2似乎​​想等待完整的POST在所有发送CGI应用程序之前,任何事情完成。

However, Apache2 seems to want to wait for the full POST to complete before sending the CGI application anything at all.

我怎么能强迫的Apache2停止缓冲后到我的CGI应用程序?

How can I force Apache2 to stop buffering the POST to my CGI application?

修改

看来,它实际上是一个的被缓冲了CGI的输出。我开始把数据传输到一个临时文件,看它的进展。这一点,我有一个问题。

It appears that it's actually the output of the CGI that's being buffered. I started streaming the data to a temp file to watch it's progress. That, and I have another problem.

1)的输出被缓冲。我试过SetEnvIf之后(和简单SETENV)的!nogzip,nogzip和!gzip的没有成功(CGI目录定义中)。

1) The output is being buffered. I've tried SetEnvIf (and simply SetEnv) for "!nogzip", "nogzip", and "!gzip" without success (within the CGI Directory definition).

2)的Apache2似乎​​不读CGI的输出,直到CGI进程退出?我注意到,我的CGI应用程序(潮红或不)被永久地挂在FWRITE(...,标准输出)行约为80K。

2) Apache2 appears to not be reading the CGI's output until the CGI process exits? I notice that my CGI app (flushing or not) is hanging up permanently on a "fwrite(..., stdout)" line at around 80K.

修改

好吧,火狐与我搞乱。如果我发送一个150K的文件,然后有80K左右没有CGI锁死。如果该文件是2G的,然后有一个锁定。因此,Firefox是不是从服务器读取的输出,同时它试图发送的文件...是否有任何页眉或备用内容类型来改变这种行为?

Okay, Firefox is messing with me. If I send a 150K file, then there's no CGI lockup around 80K. If the file is 2G, then there's a lockup. So, Firefox is not reading the output from the server while it's trying to send the file... is there any header or alternate content type to change that behavior?

修改

好吧,我想在大文件中的CGI输出锁定不重要实际。我不需要呼应文件!我调试所造成的调试工具的一个问题。 :)

Okay, I suppose the CGI output lockup on big files isn't important actually. I don't need to echo the file! I'm debugging a problem caused by debugging aids. :)

我想这个作品不够好即可。谢谢!

I guess this works well enough then. Thanks!

最后要注意

就像一记...我想是的Apache2缓冲输入的是,我始终有一个内容长度环境变量的原因。我想Firefox是足够聪明的precalculate一个多形式上传的Apache2的内容长度被路过上。我想是的Apache2缓冲输入和报告本身的长度。

Just as a note... the reason I thought Apache2 was buffering input was that I always got a "Content-Length" environment variable. I guess FireFox is smart enough to precalculate the content length of a multipart form upload and Apache2 was passing that on. I thought Apache2 was buffering the input and reporting the length itself.

推荐答案

您确定它被缓冲输入这就是问题所在?输出缓冲的问题是更常见,并且可能无法从输入缓冲区分,如果你的调试方法是一样的东西只是打印 ING的响应。

Are you sure it's the input being buffered that's the problem? Output buffering problems are much more common, and might not be distinguishable from input buffering, if your method of debugging is something like just print​ing to the response.

(输出缓冲的常见原因无论是未刷新标准输出脚本或过滤器。通常的罪魁祸首是 DEFLATE 过滤器,它经常被用来COM preSS均文本/ 的反应,他们是否来自一个静态文件或脚本。一般来说这是个好主意COM preSS脚本的输出,但一个副作用是,它会导致响应完全缓冲的。如果你需要即时响应,你需要关闭它,一个脚本或所有脚本,由限制 AddOutputFilterByType 的特定&LT的应用;目录> S,或者使用 mod_setenvif 设置!nogzip 注)

(Output buffering is commonly caused either by unflushed stdout in the script or by filters. The usual culprit is the DEFLATE filter, which is often used to compress all text/ responses, whether they come from a static file or a script. In general it's a good idea to compress the output of scripts, but a side-effect it that it will cause the response to be fully buffered. If you need immediate response, you'll need to turn it off for that one script or all scripts, by limiting the application of AddOutputFilterByType to particular <Directory>​s, or using mod_setenvif to set the !nogzip note.)

同样,输入滤波器(包括再 DEFLATE )可能导致CGI输入进行缓冲,如果你使用任何。但是,他们就不太广泛使用。

Similarly, an input filter (including, again DEFLATE) might cause CGI input to be buffered, if you're using any. But they're less widely-used.

编辑:现在,只要注释掉任何的httpd的conf已启用deflate过滤器。你可以把它放回去选择,一旦你高兴,你的IO是没有它缓冲的。

for now, just comment out any httpd conf you have enabling the deflate filter. You can put it back selectively once you're happy that your IO is unbuffered without it.

我发现我的CGI应用程序(潮红或不)被永久地挂在FWRITE(...,标准输出)行约为80K。

I notice that my CGI app (flushing or not) is hanging up permanently on a "fwrite(..., stdout)" line at around 80K.

是啊......如果你还没有看过你所有的输入,你可以尝试写输出,如果你写太多时死锁。您可以阻止在输出呼叫,等待网络缓冲区来疏通,所以你可以把你已经有了新的数据,但他们绝不会因为浏览器试图发送的所有数据前,将开始读取输出。

Yeah... if you haven't read all your input, you can deadlock when trying to write output, if you write too much. You can block on an output call, waiting for the network buffers to unclog so you can send the new data you've got, but they never will because the browser is trying to send all its data before it will start to read the output.

什么是你的工作就在这里?一般来说,没有意义编写进度信息的输出响应直接的表单POST,因为浏览器通常不会显示出来。如果你想提供一个纯HTML表单提交上传正在进行的反馈,这通常是用像有一个AJAX连接检查回黑客做在上传是怎么回事(指进度信息必须共享,例如,在数据库中),或使用Flash上​​传组件。

What are you working on here? In general it doesn't make sense to write progress-info output in response to a direct form POST, because browsers typically won't display it. If you want to provide upload-progress feedback on a plain HTML form submission, this is usually done with hacks like having an AJAX connection check back to see how the upload is going (meaning progress information has to be shared, eg. in a database), or using a Flash upload component.

这篇关于的Apache2和CGI - 如何保持阿帕奇从缓存POST数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆