close() public method

Closes the curl connection.
public close ( ) : boolean
return boolean True on closed connection
Beispiel #1
0
 public function testClose()
 {
     $stream = new Curl($this->_testConfig);
     $result = $stream->open();
     $this->assertTrue($result);
     $result = $stream->close();
     $this->assertTrue($result);
     $result = $stream->resource();
     $this->assertFalse(is_resource($result));
 }
Beispiel #2
0
 public function testSendDeleteThenGet()
 {
     $postConfig = array('method' => 'DELETE', 'body' => '');
     $stream = new Curl($this->_testConfig);
     $this->assertInternalType('resource', $stream->open());
     $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig)));
     $this->assertTrue(isset($stream->options[CURLOPT_CUSTOMREQUEST]));
     $this->assertEqual($stream->options[CURLOPT_CUSTOMREQUEST], 'DELETE');
     $this->assertTrue(isset($stream->options[CURLOPT_POSTFIELDS]));
     $this->assertEqual($stream->options[CURLOPT_POSTFIELDS], $postConfig['body']);
     $this->assertTrue($stream->close());
     $this->assertInternalType('resource', $stream->open());
     $this->assertTrue($stream->write(new Request($this->_testConfig)));
     $this->assertFalse(isset($stream->options[CURLOPT_CUSTOMREQUEST]));
     $this->assertTrue($stream->close());
 }
Beispiel #3
0
 public function close()
 {
     $this->closed = parent::close();
     return true;
 }
Beispiel #4
0
 public function testSendPostThenGet()
 {
     $postConfig = array('method' => 'POST', 'body' => '{"body"}');
     $stream = new Curl($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig)));
     $this->assertTrue(isset($stream->options[CURLOPT_POST]));
     $this->assertTrue($stream->close());
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue($stream->write(new Request($this->_testConfig)));
     $this->assertFalse(isset($stream->options[CURLOPT_POST]));
     $this->assertTrue($stream->close());
 }
 public function testSendPutThenGet()
 {
     $postConfig = array('method' => 'PUT', 'body' => '{"body"}');
     $stream = new Curl($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue($stream->write(new Request($postConfig + $this->_testConfig)));
     $this->assertTrue(isset($stream->options[CURLOPT_CUSTOMREQUEST]));
     $this->assertEqual($stream->options[CURLOPT_CUSTOMREQUEST], 'PUT');
     $this->assertTrue(isset($stream->options[CURLOPT_POSTFIELDS]));
     $this->assertEqual($stream->options[CURLOPT_POSTFIELDS], $postConfig['body']);
     $this->assertTrue($stream->close());
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue($stream->write(new Request($this->_testConfig)));
     $this->assertFalse(isset($stream->options[CURLOPT_CUSTOMREQUEST]));
     $this->assertTrue($stream->close());
 }