Re: Code updates

Miles Elam <[email protected]>
Newsgroups gmane.network.tux
Message-ID <[email protected]>
Mark Swanson wrote:

>Perhaps someone on the list could give a quick refresher given a compressed 
>index.html file the following:
>1. what is the incorrect value that was returned?
>2. what should the correct value be?
>3. are all browsers identical wrt gzip support?
>
1) The incorrect value is that Content-Length returns the uncompressed 
file size.
2) The correct value is the compressed file size.
3) IE 4 had problems with it if memory serves, but by and large, yes.

A client stalls when TUX stops sending data after N bytes where N is 
equal to the size of the compressed file.  The client retries the 
request only asking for the range of N to the end of the uncompressed 
file size.  TUX doesn't allow compressed ranges and so takes data from 
the uncompressed item.  The client ends up with a compressed file 
appended with the end of the uncompressed file.

That's for advanced clients.  Dumber clients will simply timeout with 
"only" the compressed file as data (but will probably flag it as 
incomplete or something...undefined behavior).

Now then, what I've found is that the ETag is made before the 
compression check is made.  This seems innocuous until you see that the 
size is being pulled from the ETag as an efficiency hack avoiding an 
extra sprintf().

I've hacked, compiled, and now I need to try it out.  I pretty 
confident, but the proof is in the runtime.

This is what I have done to proto_http.c:

1961,1963c1961,1973
<             // "%d" req->total_file_len
<             memcpy(curr, &req->etag, req->lendigits);
<             curr += req->lendigits;
---
 >             /* The ETag was generated with an uncompressed file's
 >              *  info.  I've left the ETag as it is, but the size
 >              *  needs to be from req->total_file_len.  In other
 >              *  words, needs to be from the compressed image if
 >              *  we're sending gzip versions.
 >              *  - [email protected] -- 2002-11-13
 >              */
 >             if (req->content_gzipped)
 >                 curr += sprintf(curr, "%Ld", req->total_file_len);
 >             else {
 >                 memcpy(curr, &req->etag, req->lendigits);
 >                 curr += req->lendigits;
 >             }

No guarantees, but I'm posting it in case I don't have time to test 
right away...

- Miles
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.