[Twisted-Python] web2: http Content-Length header

James Y Knight foom at fuhm.net
Wed Dec 6 11:23:24 EST 2006


On Dec 6, 2006, at 4:35 AM, Pieter Grimmerink wrote:

> On Wednesday 06 December 2006 01:54, David Reid wrote:
>> Why don't you just use self.length when showing the progress?
>
> The length is not passed to the Response object.
>
> twisted/web2/client/http.py line 168:
> self.response = http.Response(self.code, self.inHeaders, self.stream)
>
> This response object is then passed to the responseDefer callback,  
> which
> means we only have resultcode, headers and stream to work with.

Sorry for not responding before. The Content-Length is removed from  
the set of headers and moved to an attribute of the stream. This is  
so that if anybody does content transforms before you get the data  
(e.g. transparent uncompressing/etc), the length and the data is in  
the same place, among other reasons.

You're supposed to get the length from the stream object.  
stream.length is an integer if the content length is known, and None  
if it is not known.

James





More information about the Twisted-Python mailing list