[Zope] Problem generating Transfer-Encoding: chunked
Norbert Marrale
norbert at vsmpro.com
Sat Sep 16 16:26:35 EDT 2006
Hi All,
I'm in the process of writing a python script that goes through a long
list in batches and outputs its progress to HTML. (Zope 2.7.5 behind Apache)
The result is not what I expected: instead of returning the results in
small chunks, Zope (Apache, gremlins?) rewrites the output and returns
much larger sections of data.
If I remove the Transfer-Encoding header and replace it with a fixed
Content-Length, I can see that my script outputs its chunks as intended...
Can anyone offer suggestions?
Norbert
[Code below:]
RESPONSE=context.REQUEST.RESPONSE
RESPONSE.setHeader('Content-Type', 'text/html')
RESPONSE.setHeader('Transfer-Encoding', 'chunked')
RESPONSE.write( str(hex(len(htmlHeader)))[2:]+'\n'+htmlHeader+'\n' )
def doBatch(start, end):
-- run through list and output --
RESPONSE.write(str(hex(len(htmlContent)))[2:]+'\n'+htmlContent+'\n')
while myBatch <= numBatches and start <> -1:
start = doBatch(start,end)
end = start + batchSize
myBatch +=1
RESPONSE.write(str(hex(len(htmlFooter)))[2:]+'\n'+htmlFooter+'\n\n')
[incorrect HTML output snippet:]
HTTP/1.1 200 OK
Date: Fri, 15 Sep 2006 22:37:22 GMT
Server: Zope/(Zope 2.7.5-final, python 2.3.5, freebsd4) ZServer/1.1
Content-Type: text/html
X-Cache: MISS from xxx.xxx.xxx
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
db8
<html>
<head>
<title>Progress Report...</title>
</head>
<body>
<h2>Batch 0: 0 - 25</h2> <-- expected new chunk
<p>[data]</p>
<h2>Batch 1: 26 - 51</h2> <-- expected new chunk
<p>[data]</p>
<h2>Batch 2: 51 - 76</h2> <-- expected new chunk
<p>[data]</p>
45e
<h2>Batch 3: 76 - 101</h2> <-- why does chunk start here?
<p>[data]</p>
<hr> <-- expected new chunk
<h2>DONE!</h2>
</body>
</html>
0
More information about the Zope
mailing list