lithium\net\http\Message::__construct()
Constructor. Adds config values to the public properties when a new object is created.
Parameters
-
array
$config
The available configuration options are the following. Further options are inherited from the parent class.
'protocol'
string: Defaults tonull
.'version'
string: Defaults to'1.1'
.'scheme'
string: Overridden and defaulting to'http'
.'headers'
array: Defaults toarray()
.
Returns
voidSource
public function __construct(array $config = []) {
$defaults = [
'protocol' => null,
'version' => '1.1',
'scheme' => 'http',
'headers' => []
];
$config += $defaults;
foreach (array_intersect_key(array_filter($config), $defaults) as $key => $value) {
$this->{$key} = $value;
}
parent::__construct($config);
if (strpos($this->host, '/') !== false) {
list($this->host, $this->path) = explode('/', $this->host, 2);
}
$this->path = str_replace('//', '/', "/{$this->path}");
$this->protocol = $this->protocol ?: "HTTP/{$this->version}";
}