This stream adapter provides the required method implementations of the abstract Socket class for the open(), close(), read(), write(), timeout() eof() and encoding() methods.
See also: lithium\net\socket\Stream
Inheritance: extends lithium\net\Socket
Example #1
0
 public function testSend()
 {
     $stream = new Stream($this->_testConfig);
     $result = $stream->open();
     $data = "GET / HTTP/1.1\r\n";
     $data .= "Host: localhost\r\n";
     $data .= "Connection: Close\r\n\r\n";
     $result = $stream->send($data, array('classes' => array('response' => '\\lithium\\net\\http\\Response')));
     $this->assertNotEqual(null, $result);
 }
Example #2
0
 public function testStreamAdapter()
 {
     $socket = new Stream($this->_testConfig);
     $this->assertTrue($socket->open());
     $response = $socket->send();
     $this->assertTrue($response instanceof Response);
     $expected = 'google.com';
     $result = $response->host;
     $this->assertEqual($expected, $result);
     $result = $response->body();
     $this->assertPattern("/<title[^>]*>.*<\\/title>/im", (string) $result);
 }
Example #3
0
	public function testStreamAdapter() {
		$socket = new Stream($this->_testConfig);
		$this->assertTrue($socket->open());
		$response = $socket->send();
		$this->assertTrue($response instanceof \lithium\net\http\Response);

		$expected = 'www.lithify.me';
		$result = $response->host;
		$this->assertEqual($expected, $result);

		$result = $response->body();
		$this->assertPattern("/<title[^>]*>.*Lithium.*<\/title>/im", (string) $result);
	}
Example #4
0
 public function testSendWithObject()
 {
     $stream = new Stream($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $result = $stream->send(new Request($this->_testConfig), array('response' => 'lithium\\net\\http\\Response'));
     $this->assertTrue($result instanceof Response);
     $this->assertPattern("/^HTTP/", (string) $result);
     $this->assertTrue($stream->eof());
 }
Example #5
0
 public function testStreamAdapter()
 {
     $socket = new Stream($this->_testConfig);
     $this->assertNotEmpty($socket->open());
     $response = $socket->send();
     $this->assertInstanceOf('lithium\\net\\http\\Response', $response);
     $expected = 'google.com';
     $result = $response->host;
     $this->assertEqual($expected, $result);
     $result = $response->body();
     $this->assertPattern("/<title[^>]*>301 Moved<\\/title>/im", (string) $result);
 }