Clue\React\Buzz\Message\MessageFactory::response PHP 메소드

response() 공개 메소드

Creates a new instance of ResponseInterface for the given response parameters
public response ( string $version, integer $status, string $reason, array $headers = [], React\Stream\ReadableStreamInterface | string $body = '' ) : ResponseInterface
$version string
$status integer
$reason string
$headers array
$body React\Stream\ReadableStreamInterface | string
리턴 ResponseInterface
    public function response($version, $status, $reason, $headers = array(), $body = '')
    {
        return new Response($status, $headers, $this->body($body), $version, $reason);
    }

Usage Example

예제 #1
0
 public function testReceivingStreamingBodyWillResolveWithStreamingResponseIfStreamingIsEnabled()
 {
     $messageFactory = new MessageFactory();
     $request = $this->getMock('Psr\\Http\\Message\\RequestInterface');
     $response = $messageFactory->response(1.0, 200, 'OK', array(), $this->getMock('React\\Stream\\ReadableStreamInterface'));
     // mock sender to resolve promise with the given $response in response to the given $request
     $sender = $this->getMockBuilder('Clue\\React\\Buzz\\Io\\Sender')->disableOriginalConstructor()->getMock();
     $sender->expects($this->once())->method('send')->with($this->equalTo($request))->willReturn(Promise\resolve($response));
     $transaction = new Transaction($request, $sender, array('streaming' => true), $messageFactory);
     $promise = $transaction->send();
     $response = Block\await($promise, $this->getMock('React\\EventLoop\\LoopInterface'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('', (string) $response->getBody());
 }
All Usage Examples Of Clue\React\Buzz\Message\MessageFactory::response