Index: includes/browser.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/browser.inc,v
retrieving revision 1.1
diff -u -r1.1 browser.inc
--- includes/browser.inc	17 Aug 2009 06:08:46 -0000	1.1
+++ includes/browser.inc	21 Aug 2009 02:25:09 -0000
@@ -207,6 +207,31 @@
   }
 
   /**
+   * Get HTTP authentication information.
+   *
+   * @return
+   *   Authentication information in the format, username:password.
+   */
+  public function getHttpAuthentication() {
+    if (isset($this->requestHeaders['Authorization'])) {
+      return base64_decode($this->requestHeaders['Authorization']);
+    }
+    return NULL;
+  }
+
+  /**
+   * Set HTTP authentication information.
+   *
+   * @param $user
+   *   HTTP authentication username, which cannot contain a ":".
+   * @param $pass
+   *   HTTP authentication password.
+   */
+  public function setHttpAuthentication($user, $pass) {
+    $this->requestHeaders['Authorization'] = base64_encode("$user:$pass");
+  }
+
+  /**
    * Get the URL of the current page.
    *
    * @return
@@ -660,6 +685,9 @@
     $this->headers = array();
 
     // Ensure that request headers are up to date.
+    if ($this->getHttpAuthentication()) {
+      curl_setopt($this->handle, CURLOPT_USERPWD, $this->getHttpAuthentication());
+    }
     curl_setopt($this->handle, CURLOPT_USERAGENT, $this->requestHeaders['User-Agent']);
     curl_setopt($this->handle, CURLOPT_HTTPHEADER, $this->requestHeaders);
 
