In common.inc :
'Content-Length' => 'Content-Length: '. strlen($data)
would not work with some servers because IIS, for exemple, won't accept a length parameter equal to 0. One suggestion can be checking if $data is NULL and if so not send 'Content-Length' altough RFC say that it SHOULD be sent.

Regards

Comments

falcon9xr’s picture

I found this line in the 4.6.3 common.inc on line 295.

Centove’s picture

Apache with mod_security enabled can trigger 403 errors with a content-length: 0 header sent. (for whatever reason)

This patch will only append the Content-Length header if we have content.

--- /home/gregm/drupal-4.7.2/includes/common.inc        2006-05-15 16:53:26.000000000 -0400
+++ www/localhost/htdocs/includes/common.inc    2006-07-12 08:25:06.000000000 -0400
@@ -399,9 +399,10 @@
     // We don't add the port to prevent from breaking rewrite rules checking
     // the 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)
-  );
+    'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)');
+    if (!empty($data)) {
+       $defaults['Content-Length'] = 'Content-Length:' . strlen($data);
+    }

   foreach ($headers as $header => $value) {
     $defaults[$header] = $header .': '. $value;
magico’s picture

Version: 4.6.2 » 4.6.9
Component: aggregator.module » base system
Status: Active » Needs work

Must create a patch for 4.6.9
Checked the current HEAD and the bug is there too.

magico’s picture

Version: 4.6.9 » x.y.z
Priority: Minor » Normal
Status: Needs work » Needs review
StatusFileSize
new669 bytes

Following the advice by dlr and Centove here are the patches for CVS, 4.7 and 4.6

Anyway, this must be discussed further because these would be patches to solve both IIS and Apache bugs, as it seems.

drumm’s picture

Status: Needs review » Needs work

Please post each patch separately and unarchived.

magico’s picture

StatusFileSize
new621 bytes

4.6.9

magico’s picture

StatusFileSize
new697 bytes

4.7.3

magico’s picture

Status: Needs work » Needs review
StatusFileSize
new697 bytes

HEAD (2006-08-29)

killes@www.drop.org’s picture

I don't quite understand why we need this patch. Drupal has been reported to work on IIS just fine. I don't think we have business supporting broken servers.

chx’s picture

Status: Needs review » Closed (won't fix)

http://www.ngssoftware.com/papers/iisrconfig.pdf

Note the Content-Length header is required even though there is no content and hence the length
is 0.

http://www.mail-archive.com/squid-users@squid-cache.org/msg40113.html

If you can, sending Content-Length is always best.