Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.50
diff -u -p -r1.756.2.50 common.inc
--- includes/common.inc	30 Apr 2009 00:39:01 -0000	1.756.2.50
+++ includes/common.inc	10 May 2009 12:07:39 -0000
@@ -484,9 +484,16 @@ function drupal_http_request($url, $head
     // host that do not take into account the port number.
     'Host' => "Host: $host",
     'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)',
-    'Content-Length' => 'Content-Length: '. strlen($data)
   );
 
+  // Only add Content-Length if we actually have any content or if it is a POST
+  // or PUT request. Some non-standard servers get confused by Content-Length in
+  // at least HEAD/GET requests, and Squid always requires Content-Length in
+  // POST/PUT requests.
+  if (!empty($data) || $method == 'POST' || $method == 'PUT') {
+    $defaults['headers']['Content-Length'] = strlen($data);
+  }
+
   // If the server url has a user then attempt to use basic authentication
   if (isset($uri['user'])) {
     $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
