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	23 Nov 2008 03:20:34 -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,6 +851,8 @@ 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.
+    $this->_headers[] = $header;
     // This is required by cURL.
     return strlen($header);
   }
@@ -1324,6 +1328,35 @@ 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) {
+    $i = 0;
+    foreach ($this->_headers as $header) {
+      $header = trim($header);
+      if ($header === '') {
+        $i++;
+      }
+      else {
+        list($name, $value) = explode(':', $header, 2);
+        if (isset($headers[$i][$name])) {
+          $headers[$i][$name] .= ','. trim($value);
+        }
+        else {
+          $headers[$i][$name] = trim($value);
+        }
+      }
+    }
+    if (!$all) {
+      $headers = array_pop($headers);
+    }
+    return $headers;
+  }
+
+  /**
    * Gets the current raw HTML of requested page.
    */
   function drupalGetContent() {
