diff --git a/src/Purl.php b/src/Purl.php index 41189f0..31db926 100644 --- a/src/Purl.php +++ b/src/Purl.php @@ -205,7 +205,12 @@ public function execute() if (isset($this->_options[CURLOPT_COOKIE])) { $this->_headers['Cookie'] = $this->_options[CURLOPT_COOKIE]; } - + + // Support basic authentication + if (isset($this->_options[CURLOPT_USERPWD])) { + $this->_headers['Authorization'] = 'Basic ' . base64_encode($this->_options[CURLOPT_USERPWD]); + } + if ($this->_headers) { foreach ($this->_headers as $name => $value) { $headers .= $name . ': ' . $value . "\r\n"; @@ -319,4 +324,4 @@ private function _errorHandler() $this->_errorno = 100; } } -} \ No newline at end of file +}