问题描述
我正在使用一个PHP Webapp,它接受来自特定客户端的大型POST文件上传,并希望在使用HTTP上传文件之前(基于各种标头和其他因素,不仅仅是大小)接受或拒绝这些上传(基于各种标头和其他因素,不仅仅是大小)/1.1 100继续.
I'm working on a PHP webapp that accepts large POSTed file uploads from specific clients and would like to accept or reject these uploads (based on various headers and other factors, not just size) before the file is uploaded by using HTTP/1.1 100 Continue.
问题是Apache从客户端看到Expect:100-continue,返回100 Continue,并在PHP开始处理之前接受所有文件上传...但是,我需要PHP在Expect:100-之后立即开始处理继续.我不确定是否可行,所以我有两个问题:
The problem is that Apache sees the Expect: 100-continue from the client, returns a 100 Continue and accepts the file upload all before PHP begins processing... However I need PHP to begin processing immediately after the Expect: 100-continue. I'm not sure if this is possible so I have two questions:
- 是否可以使PHP在Expect:100-continue之后立即开始处理?
- 如果没有,什么是替代品?
我目前正在考虑通过指定客户端首先发送具有与POST相同的标头的HEAD请求来模拟100继续.然后,Web应用程序可以返回响应以继续POST或错误代码.欢迎其他建议!
I'm currently thinking of emulating 100 continue by specifying the client first send a HEAD request with the same headers as the POST. The webapp can then return a response to continue with the POST or an error code. Other suggestions are welcome!
推荐答案
不幸的是,我认为这是不可能的.如果这是真正的要求,我认为最好只是看看其他语言.我认为今天的异构环境比写此问题时更为普遍,所以为什么不创建一个用其他某种语言编写的小型服务来处理上载.
Unfortunately I don't think this is possible. If this is a real requirement, I think it's best to simply look at other languages. I think today heterogeneous environments are more common than when this question was written, so why not create a small service written in some other language that just deals with the upload.
但是,是的,PHP的工作方式是仅在客户端发送整个请求时脚本才启动.
But yea, the way PHP works is that the script only starts when the entire request is sent by the client.
这篇关于支持HTTP 100继续使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!