/** * @param Net_HTTP_Response $response * * @return Net_HTTP_Response */ public function dump(Net_HTTP_Response $response) { $response->header('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2')->header('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3')->header('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); $response->headers($this->convert_to_headers()); return $response; }
/** * @param string $string * * @return Net_HTTP_Response */ public static function from_string(&$body, &$header) { $response = new Net_HTTP_Response(); $header = preg_replace('!HTTP/\\d.\\d\\s+100\\s+Continue\\s+!', '', $header); $m = array(); $status = ''; foreach (explode("\n", $header) as $line) { if (!$status && preg_match('{^HTTP/\\d\\.\\d\\s+(\\d+(?:\\s+.+))}', $line, $m)) { $status = $m[1]; } if (preg_match("{([^:]+):\\s*(.*)}", $line, $m)) { $response->header($m[1], $m[2]); } } list($code, $message) = explode(" ", preg_replace('{\\s+}', ' ', (string) $status), 2); return $response->status($code, trim($message))->body($body); }