支持HTTP 100继续使用PHP [英] Supporting HTTP 100 Continue with PHP

查看:109
本文介绍了支持HTTP 100继续使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个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.

HTTP/1.1规范8.2.3 :

100(继续)状态的目的(请参见第10.1.1节)是为了允许正在发送带有请求正文的请求消息的客户端确定源服务器是否愿意接受请求(基于客户端发送请求正文之前).在某些情况下,如果服务器在不查看正文的情况下拒绝邮件,则客户端发送正文可能是不合适的,或者效率很低.

The purpose of the 100 (Continue) status (see section 10.1.1) is to allow a client that is sending a request message with a request body to determine if the origin server is willing to accept the request (based on the request headers) before the client sends the request body. In some cases, it might either be inappropriate or highly inefficient for the client to send the body if the server will reject the message without looking at the body.

问题是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:

  1. 是否可以使PHP在Expect:100-continue之后立即开始处理?
  2. 如果没有,什么是替代品?

我目前正在考虑通过指定客户端首先发送具有与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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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