/** * @param resource a file stream * @return Bringit_Header_ResponseHeader */ public function parseStream($stream) { $statusLine = Bringit_Header_ResponseStatusLine::fromString(fgets($stream)); // TODO: handle folding/continuation // @see http://tools.ietf.org/html/rfc2616#section-2.2 $headers = array(); while (!feof($stream)) { $line = fgets($stream); if ($line === "\r\n") { break; } else { $headers[] = Bringit_Header_HeaderField::fromString($line); } } return new Bringit_Header_ResponseHeader($statusLine, $headers); }
public function testRoundTrip() { $string = "Test: blarg: meh\r\n"; $this->assertEqual(Bringit_Header_HeaderField::fromString($string)->__toString(), $string); }