--- ./includes/common.inc.orig	2010-03-04 01:15:28.000000000 +0100
+++ ./includes/common.inc	2010-03-25 19:35:37.000000000 +0100
@@ -460,6 +460,9 @@ function drupal_http_request($url, $head
     return $result;
   }
 
+  timer_start(__FUNCTION__);
+  $option_timeout = ini_get('default_socket_timeout');
+
   switch ($uri['scheme']) {
     case 'http':
       $port = isset($uri['port']) ? $uri['port'] : 80;
@@ -548,8 +551,12 @@ function drupal_http_request($url, $head
 
   // Fetch response.
   $response = '';
-  while (!feof($fp) && $chunk = fread($fp, 1024)) {
-    $response .= $chunk;
+
+  $timeout = $option_timeout - timer_read(__FUNCTION__) / 1000;
+  while (($timeout > 0) && !feof($fp)) {
+    $timeout = $option_timeout - timer_read(__FUNCTION__) / 1000;
+    stream_set_timeout($fp, floor($timeout), floor(1000000 * fmod($timeout, 1)));
+    $response .= fread($fp, 1024);
   }
   fclose($fp);
 
