Page 1 of 1

filtering input from one stream into another

Posted: Sun Jun 21, 2009 7:31 am
by danc81
What would be the best way to accomplish this in PHP?

I need to read data coming in via php://input, check the data for a particular marker and write the data out to another stream up to the marker.

This sounds easy and I've got it working great when outputting to a file but I need to output to another HTTP stream using CURL. I was thinking that maybe there is a way to open a memory stream and duplicate the handle, letting the input code keep writing to it while CURL is reading from it but I can't figure what would be the best way to go about it.

Is there a way to do something like this in PHP?

Re: filtering input from one stream into another

Posted: Tue Jun 23, 2009 3:38 pm
by patrickmvi
What is this second stream that you're talking about? I understand that you want to read in data from one stream and provide it to another but I'd like a better description on what you're trying to do so that I can better understand the issue.

Re: filtering input from one stream into another

Posted: Tue Jun 23, 2009 4:14 pm
by danc81
Hi,

Thanks for your interest. I have actually solved the problem now by implementing a StreamWrapper class to wrap the incoming stream and do the processing on the way in before the data is read.