コード例 #1
0
ファイル: Browser.php プロジェクト: clue/buzz-react
 public function send(RequestInterface $request)
 {
     if ($this->baseUri !== null) {
         // ensure we're actually below the base URI
         $request = $request->withUri($this->messageFactory->expandBase($request->getUri(), $this->baseUri));
     }
     $transaction = new Transaction($request, $this->sender, $this->options, $this->messageFactory);
     return $transaction->send();
 }
コード例 #2
0
ファイル: TransactionTest.php プロジェクト: clue/buzz-react
 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());
 }