headers->get('content-type'); $content_type = clean_content_type($content_type); // how big of data can we expect? $content_length = $event['response']->headers->get('content-length'); // we stream if content is not of "text" content-type or if its size exceeds 5 megabytes if(!in_array($content_type, $this->output_buffer_types) || $content_length > $this->max_content_length){ $this->stream = true; $event['response']->sendHeaders(); // it is of no use for us to buffer the data since we're sending it out immediately, but sometimes we must do both, hence the parameter if(!$event['request']->params->has('force_buffering')){ $event['proxy']->setOutputBuffering(false); } } } public function onCurlWrite(ProxyEvent $event){ if($this->stream){ echo $event['data']; flush(); } } public function onCompleted(ProxyEvent $event){ // if this was a streaming response then exit the script immediately since we do not wish to process it any futher if($this->stream){ exit; } } } ?>