Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.769
diff -u -r1.769 common.inc
--- includes/common.inc	26 May 2008 17:12:54 -0000	1.769
+++ includes/common.inc	27 May 2008 02:51:49 -0000
@@ -414,6 +414,7 @@
  *   data and redirect status.
  */
 function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
+  global $db_prefix;
   static $self_test = FALSE;
   $result = new stdClass();
   // Try to clear the drupal_http_request_fails variable if it's set. We
@@ -482,6 +483,16 @@
     $defaults['Authorization'] = 'Authorization: Basic ' . base64_encode($uri['user'] . (!empty($uri['pass']) ? ":" . $uri['pass'] : ''));
   }
 
+  // If the database prefix is being used by SimpleTest to run the tests in a copied
+  // database then set the user-agent header to the database prefix so that any
+  // calls to other Drupal pages will run the SimpleTest prefixed database. The
+  // user-agent is used to ensure that multiple testing sessions running at the
+  // same time won't interfere with each other as they would if the database
+  // prefix were stored statically in a file or database variable.
+  if (preg_match("/^simpletest\d+/", $db_prefix)) {
+    $headers['User-Agent'] = $db_prefix;
+  }
+
   foreach ($headers as $header => $value) {
     $defaults[$header] = $header . ': ' . $value;
   }
