Reading “chunked” POST data in PHP

▼魔方 西西 提交于 2019-12-07 09:31:50

问题


I'm trying to read the POST data from a request with "Transfer-Encoding: chunked" while it's being sent but can't get the script to fire until after all of the data has been received, is it possible to get PHP to be able to react to a chunked request as it's coming through?

Using PHP 5.3.8 with Apache.


回答1:


The current Apache API does not provide the ability to invoke a response handler before the request has been completely received. It is not possible for any module (mod_php, mod_cgi et al) to start processing and respond to the request until the handler phase, and he Apache core does not reach this phase until after the request has been completely received and preliminary processing/parsing checks have completed.

It is unusual to send a chunked stream as a request, normally something like this is a response. HTTP is a protocol designed primarily for one-to-many content delivery - an HTTP server is expecting to server content to many clients, rather than to have many clients deliver content to it. Normally to achieve this you would invoke a script on the server that will connect to the remote stream (be the requester).

What exactly are you trying to do? What content are you trying to deliver? Do you have control over both ends of the connection?



来源:https://stackoverflow.com/questions/9991345/reading-chunked-post-data-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!