lithium\net\socket\Context::read PHP Method

read() public method

Reads from the socket. Does not apply to this implementation.
public read ( ) : boolean | string
return boolean | string
    public function read()
    {
        if (!is_resource($this->_resource)) {
            return false;
        }
        $meta = stream_get_meta_data($this->_resource);
        if (isset($meta['wrapper_data'])) {
            $headers = join("\r\n", $meta['wrapper_data']) . "\r\n\r\n";
        } else {
            $headers = null;
        }
        return $headers . stream_get_contents($this->_resource);
    }

Usage Example

Example #1
0
	public function testWriteAndRead() {
		$stream = new Context($this->_testConfig);
		$this->assertTrue(is_resource($stream->open()));
		$this->assertTrue(is_resource($stream->resource()));
		$this->assertEqual(1, $stream->write());
		$this->assertPattern("/^HTTP/", (string) $stream->read());
	}