从 PHP/Apache 返回 100-Continue [英] Returning 100-Continue from PHP/Apache

查看:26
本文介绍了从 PHP/Apache 返回 100-Continue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来防止脚本将不必要的数据上传到 PHP 脚本.我最初试图终止显然违反 HTTP 协议的传入读取连接,但我无法使其工作,但我一直在研究替代方案,发现 100-Continue 状态代码正是我需要.我的客户端应该发送所需的标头和 Expect: 100 标头,服务器应该发回 100 Continue417 Expectation failed 但它似乎来自我试图使 100 响应在 PHP 有机会进行任何处理之前由 Apache 发回.有没有办法让 PHP 检查请求标头并发回 100 Continue 响应并继续处理传入的数据?我已经从 php://input 读取了原始数据.

I'm trying to find a way to prevent a script uploading unnecessary data to a PHP script. I had originally tried to kill the incoming read connection which is obviously against the HTTP protocol and I couldn't make it work but I have been researching alternatives and found that the 100-Continue status code is exactly what I need. My client should send the required headers and Expect: 100 header and the server should send back either 100 Continue or 417 Expectation failed but it seems from my attempts to make this work that the 100 response is sent back by Apache before PHP has a chance to do any processing. Is there a way to have PHP examine the request headers and send back a 100 Continue response and continue to process the incoming data? I'm already read the raw data from php://input.

谢谢,J

推荐答案

您不能在纯 PHP 代码中执行此操作(在上传完成之前不会执行),但您可以创建一个 PHP 扩展.也许看一下与上传过程挂钩的 uploadprogress 扩展.

You cannot do it in pure PHP code (which isn't executed until the upload is complete), but you can create a PHP extension. Maybe take a look at the uploadprogress extension which hooks into the upload process.

这篇关于从 PHP/Apache 返回 100-Continue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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