public function onHeadersReceived(ProxyEvent $event) { // what content type are we dealing with here? can be empty $content_type = $event['response']->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); } } }
function is_html($content_type) { return clean_content_type($content_type) == 'text/html'; }
function is_html($content_type) { $content_type = clean_content_type($content_type); $text = array('text/html'); return in_array($content_type, $text); }