username) && !empty($this->password)) { switch ($this->authType) { case 'basic': curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); break; case 'digest': curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); break; case 'ntlm': curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); break; case 'gss': curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_GSSNEGOTIATE); break; default: curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); } curl_setopt($ch, CURLOPT_USERPWD, sprintf('%s:%s', $this->username, $this->password)); } $response = curl_exec($ch); $this->info = curl_getinfo($ch); if ($response === false) { $this->error = curl_error($ch); } curl_close($ch); return $this; } protected function getHeader($ch, $header) { $i = strpos($header, ':'); if (!empty($i)) { $key = strtolower(substr($header, 0, $i)); $value = trim(substr($header, $i + 2)); $this->responseHeaders[$key] = $value; } return strlen($header); } public function getError() { return $this->error; } public function getResponseHeaders() { return $this->responseHeaders; } public function getHttpCode() { return isset($this->info['http_code']) ? $this->info['http_code'] : null; } public function setAuthType($type) { $type = strtolower($type); if (in_array($type, array('basic', 'digest', 'gss', 'ntlm'))) { $this->authType = $type; } return $this; } public function setUsername($username) { $this->username = $username; return $this; } public function setPassword($password) { $this->password = $password; return $this; } } ?>