public function open(array $options = array())
{
parent::open($options);
$config = $this->_config;
if (!$config['scheme'] || !$config['host']) {
return false;
}
$url = "{$config['scheme']}://{$config['host']}:{$config['port']}";
$context = array($config['scheme'] => array('timeout' => $this->_timeout));
if (is_object($config['message'])) {
$url = $config['message']->to('url');
$context = $config['message']->to('context', array('timeout' => $this->_timeout));
}
$this->_resource = fopen($url, $config['mode'], false, stream_context_create($context));
return $this->_resource;
}
public function testWriteAndRead() { $stream = new Context($this->_testConfig); $this->assertTrue(is_resource($stream->open())); $this->assertTrue(is_resource($stream->resource())); $response = $stream->send(new Request(), array('response' => 'lithium\\net\\http\\Response')); $this->assertTrue($response instanceof Response); $this->assertEqual(trim(file_get_contents($this->_testUrl)), trim($response->body())); $this->assertTrue($stream->eof()); }