Ejemplo n.º 1
0
Archivo: HTTP.php Proyecto: techart/tao
 /**
  * @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);
 }