lithium\net\http\Service::__construct PHP Method

__construct() public method

Constructor. Initializes a new Service instance with the default HTTP request settings and transport- and format-handling classes.
public __construct ( array $config = [] ) : void
$config array Available configuration options are: - `'persistent'` _boolean_ - `'scheme'` _string_ - `'host'` _string_ - `'port'` _integer_ - `'timeout'` _integer_ - `'auth'` _boolean_ - `'username'` _string_ - `'password'` _string_ - `'encoding'` _string_ - `'socket'` _string_
return void
    public function __construct(array $config = array())
    {
        $defaults = array('persistent' => false, 'scheme' => 'http', 'host' => 'localhost', 'port' => null, 'timeout' => 30, 'auth' => null, 'username' => null, 'password' => null, 'encoding' => 'UTF-8', 'socket' => 'Context');
        parent::__construct($config + $defaults);
    }

Usage Example

 /**
 * Constructor. Expects a connection configured like the following:
 * 
 * Connections::add('freshbooks', array(
 * 	'host' => 'yourusername.freshbooks.com',
 * 	'token' => 'tokengoeshere',
 * );
 *
 * @param array $config 
 * @author John Anderson
 */
 public function __construct(array $config = array())
 {
     $this->_connection = Connections::get('freshbooks', array('config' => true));
     $defaults = array('scheme' => 'https', 'host' => trim($this->_connection['host']), 'socket' => 'Curl', 'username' => trim($this->_connection['token']), 'password' => 'X', 'encoding' => 'UTF-8');
     parent::__construct($config + $defaults);
 }
All Usage Examples Of lithium\net\http\Service::__construct