Subject: Re: [htdig3-dev] size of dynamic pages
From: Gilles Detillieux (email@example.com)
Date: Tue Feb 08 2000 - 08:31:05 PST
According to me:
> >The new code obviously assumes the Content-Length header will always be
> >given - a very wrong assumption. The code in ReadBody seems to work as
> >the old code did, where it will ignore a negative content_length setting
> >(which meant it didn't see the header). However, the HtHTTP_Response
> >constructor doesn't initialise it to -1. I think there will be a few
> >other tests for this that will need to be reinserted as well.
OK, I didn't look deep enough yesterday. HtHTTP_Response's constructor
doesn't initialise it to -1, but the Transport_Response constructor does,
as does its Reset() method, so that works as it should.
According to Gabriele Bartolini:
> I'll check better but, as far as I know, the code doesn't assume the
> Content-Length header is always given. Indeed, more often, server answer by
> giving you a chunked-body with dynamic size. The new code supports this as
> the RFC of HTTP 1.1 says (not completely, because I think there's a part of
> the response we can ignore). In this case Content-Length is not given ...
> and I forgot to set the document size of the response in the
> ReadChunkedBody() function. In fact, I had the content-length set properly,
> but not the document size ... Yesterday I committed the change and now,
> chunked bodies response have a right size (as far as I tested).
> Of course, if I have enough time, I'll try to give a another look at the
> code and you all please test the code.
I did find a problem in ReadChunkedBody(). It appends to the _contents
string using "<<", rather than using
as ReadBody() does. The "<<" will fail if there are any null characters
in the buffer, which may not be a problem for text/* content types,
but will be for binary files.
Also, ReadBody() and ReadChunkedBody() are inconsistent in the way they
set _response._content_length & _response._document_length. ReadBody()
doesn't even make sure _response._content_length gets set. They should
both end with something like:
_response._document_length = _response._contents.length();
if (_response._content_length < _response._document_length)
_response._content_length = _response._document_length;
Either that, or this should be done once in HtHTTP::HTTPRequest(),
after one or the other of the Read*Body() methods is called. I'm not
completely clear on the chunked v. unchunked reading, but it seems to me
this should not affect how the content length and type are processed.
If it's guaranteed that when the body is chunked, there will be no
Content-Length header, then I guess the comparison between _content_length
and _document_length is not needed, and you can just set _content_length
Any comments on these suggested changes?
-- Gilles R. Detillieux E-mail: <firstname.lastname@example.org> Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil Dept. Physiology, U. of Manitoba Phone: (204)789-3766 Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930
------------------------------------ To unsubscribe from the htdig3-dev mailing list, send a message to email@example.com You will receive a message to confirm this.
This archive was generated by hypermail 2b28 : Tue Feb 08 2000 - 08:38:25 PST