public function stream(Git_HTTP_Command $command) { $cwd = '/tmp'; $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w")); if (ForgeConfig::get('sys_logger_level') == Logger::DEBUG) { $descriptorspec[2] = array('file', ForgeConfig::get('codendi_log') . '/git_http_error_log', 'a'); } $pipes = array(); $this->logger->debug('Command: ' . $command->getCommand()); $this->logger->debug('Environment: ' . print_r($command->getEnvironment(), true)); $process = proc_open($command->getCommand(), $descriptorspec, $pipes, $cwd, $command->getEnvironment()); if (is_resource($process)) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { fwrite($pipes[0], file_get_contents('php://input')); } fclose($pipes[0]); $first = true; while ($result = stream_get_contents($pipes[1], self::CHUNK_LENGTH)) { if ($first) { list($headers, $body) = http_split_header_body($result); foreach (explode("\r\n", $headers) as $header) { header($header); } file_put_contents('php://output', $body); } else { file_put_contents('php://output', $result); } $first = false; } fclose($pipes[1]); $return_value = proc_close($process); } }