Example #1
0
 /**
  * @covers ::getContent
  */
 public function testInstanceKeepsBody()
 {
     $header = $this->prophesize('\\Crunch\\FastCGI\\Protocol\\Header');
     $header->getLength()->willReturn(3);
     $record = new Record($header->reveal(), 'foo');
     self::assertEquals('foo', $record->getContent());
 }
Example #2
0
 /**
  * @param Record $record
  *
  * @return Response|null
  * @throws \RuntimeException
  */
 public function pushRecord(Record $record)
 {
     switch (true) {
         case $record->getType()->isStdout():
             $this->stdout .= $record->getContent();
             break;
         case $record->getType()->isStderr():
             $this->stderr .= $record->getContent();
             break;
         case $record->getType()->isEndRequest():
             return new Response($this->requestId, new StringReader($this->stdout), new StringReader($this->stderr));
             break;
         default:
             throw new \RuntimeException(sprintf('Unknown package type \'%d\'', $record->getType()));
             break;
     }
 }
Example #3
0
 /**
  * @param Record $record
  *
  * @return RequestInterface|null
  */
 public function pushRecord(Record $record)
 {
     $this->records[] = $record;
     if (!$record->getType()->isStdin() || $record->getContent()) {
         return;
     }
     return $this->buildRequest();
 }