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

Pieter Grimmerink mailinglists at grimmerink.nl
Tue Dec 5 16:55:37 EST 2006


On Monday 04 December 2006 22:16, Pieter Grimmerink wrote:
> Is it really necessary to remove the content-length header from the
> response?

Correction, it turns out indeed it has to be removed. If it isn't stripped 
from the response, somehow the download stops after a single block of data 
has been received.

Since the content-length is saved in self.length, the following could be a 
workaround (and it does work fine here):

Add the Content-Length header again after calling setConnectionParams, at 
the bottom of allHeadersReceived (line 195 twisted/web2/channel/http.py)

  self.inHeaders.setHeader('Content-Length', str(self.length))

What exactly goes wrong with setConnectionParams when the Content-Length 
header is not (temporarily) removed is not 100% clear to me, so there 
probably are better solutions for this problem.

Regards, Pieter




More information about the Twisted-Python mailing list