public function testHeaderOverflowShouldEmitError()
{
$error = null;
$passedParser = null;
$parser = new RequestHeaderParser();
$parser->on('headers', $this->expectCallableNever());
$parser->on('error', function ($message, $parser) use(&$error, &$passedParser) {
$error = $message;
$passedParser = $parser;
});
$this->assertSame(1, count($parser->listeners('headers')));
$this->assertSame(1, count($parser->listeners('error')));
$data = str_repeat('A', 4097);
$parser->feed($data);
$this->assertInstanceOf('OverflowException', $error);
$this->assertSame('Maximum header size of 4096 exceeded.', $error->getMessage());
$this->assertSame($parser, $passedParser);
$this->assertSame(0, count($parser->listeners('headers')));
$this->assertSame(0, count($parser->listeners('error')));
}