/** * Test the send method * * @return void */ public function testSend() { $stream = new Stream(); $request = new Request(); $request->url('http://localhost')->header('User-Agent', 'CakePHP TestSuite')->cookie('testing', 'value'); $responses = $stream->send($request, []); $this->assertInstanceOf('Cake\\Network\\Http\\Response', $responses[0]); }
/** * Test the send method * * @return void */ public function testSend() { $stream = new Stream(); $request = new Request(); $request->url('http://localhost')->header('User-Agent', 'CakePHP TestSuite')->cookie('testing', 'value'); try { $responses = $stream->send($request, []); } catch (\Cake\Core\Exception\Exception $e) { $this->markTestSkipped('Could not connect to localhost, skipping'); } $this->assertInstanceOf('Cake\\Network\\Http\\Response', $responses[0]); }
/** * Send a request. * * Used internally by other methods, but can also be used to send * handcrafted Request objects. * * @param \Cake\Network\Http\Request $request The request to send. * @param array $options Additional options to use. * @return \Cake\Network\Http\Response */ public function send(Request $request, $options = []) { $responses = $this->_adapter->send($request, $options); $url = $request->url(); foreach ($responses as $response) { $this->_cookies->store($response, $url); } return array_pop($responses); }
/** * Test that an exception is raised when timed out. * * @expectedException \Cake\Core\Exception\Exception * @expectedExceptionMessage Connection timed out cakephp://dummy/?sleep * @return void */ public function testMissDeadline() { $request = new Request(); $request->url('cakephp://dummy/?sleep'); $options = ['timeout' => 2]; $stream = new Stream(); $stream->send($request, $options); }