Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.56
diff -u -p -r1.56 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	9 Nov 2008 03:07:54 -0000	1.56
+++ modules/simpletest/drupal_web_test_case.php	20 Nov 2008 17:59:58 -0000
@@ -6,6 +6,7 @@
  */
 class DrupalWebTestCase {
   protected $_logged_in = FALSE;
+  protected $_headers;
   protected $_content;
   protected $_url;
   protected $plain_text;
@@ -828,6 +829,7 @@ class DrupalWebTestCase {
     $this->curlConnect();
     $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
     curl_setopt_array($this->ch, $this->curl_options + $curl_options);
+    $this->_headers = array();
     $this->drupalSetContent(curl_exec($this->ch), curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL));
     $this->assertTrue($this->_content !== FALSE, t('!method to !url, response is !length bytes.', array('!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), '!url' => $url, '!length' => strlen($this->_content))), t('Browser'));
     return $this->drupalGetContent();
@@ -849,8 +851,25 @@ class DrupalWebTestCase {
       // Call DrupalWebTestCase::error() with the parameters from the header.
       call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
     }
+    // Save header to the _headers array.
+    static $i = 0;
+    $i = empty($this->_headers) ? 0 : $i;
+    $length = strlen($header);
+    $header = trim($header);
+    if ($header === '') {
+      $i++;
+    }
+    else {
+      list($name, $value) = explode(':', $header, 2);
+      if (isset($this->_headers[$i][$name])) {
+        $this->_headers[$i][$name] .= ','. trim($value);
+      }
+      else {
+        $this->_headers[$i][$name] = trim($value);
+      }
+    }
     // This is required by cURL.
-    return strlen($header);
+    return $length;
   }
 
   /**
@@ -1324,6 +1343,20 @@ class DrupalWebTestCase {
   }
 
   /**
+   * Gets the current HTTP headers of the requested page.
+   *
+   * @param $all
+   *   Return an array of header arrays if TRUE, the last header array if FALSE.
+   */
+  function drupalGetHeaders($all = FALSE) {
+    $headers = $this->_headers;
+    if (!$all) {
+      $headers = array_pop($headers);
+    }
+    return $headers;
+  }
+
+  /**
    * Gets the current raw HTML of requested page.
    */
   function drupalGetContent() {
