This patch solves some problems in wget and Firefox, when doing a partial request (Range:) on a file on a Plan 9 httpd. The Plan 9 httpd does not send out a Content-Length: when doing so, but these applications expect to have one and show it directly to the user. One clause in the HTTP 1.1 RFC says in section 4.4 Message Length: "For compatibility with HTTP/1.0 applications, HTTP/1.1 requests contain- ing a message-body MUST include a valid Content-Length header field unless the server is known to be HTTP/1.1 compliant." Compliant or not complianet - here is the patch. Notes: Thu Oct 13 07:24:23 EDT 2005 rsc Installed and running on the plan9.bell-labs.com web server. Please be more careful about spacing issues -- make the spacing on changed code look like the spacing around it. Thanks. Reference: /n/sources/patch/applied/httpd-range-compliance Date: Thu Oct 13 09:40:19 CES 2005 Reviewed-by: rsc --- /sys/src/cmd/ip/httpd/sendfd.c Thu Oct 13 09:40:10 2005 +++ /sys/src/cmd/ip/httpd/sendfd.c Thu Oct 13 09:40:07 2005 @@ -125,9 +125,10 @@ r = c->head.range; if(r == nil) hprint(hout, "Content-Length: %lld\r\n", length); - else if(r->next == nil) + else if(r->next == nil) { hprint(hout, "Content-Range: bytes %ld-%ld/%lld\r\n", r->start, r->stop, length); - else{ + hprint(hout, "Content-Length: %ld\r\n", r->stop - r->start); + } else{ multir = 1; boundary = hmkmimeboundary(c); hprint(hout, "Content-Type: multipart/byteranges; boundary=%s\r\n", boundary); @@ -195,6 +196,7 @@ hprint(hout, "\r\n--%s\r\n", boundary); printtype(hout, type, enc); hprint(hout, "Content-Range: bytes %ld-%ld/%lld\r\n", r->start, r->stop, length); + hprint(hout, "Content-Length: %ld\r\n", r->stop - r->start); hprint(hout, "\r\n"); } hflush(hout);