01-07-06 07:46 AM
[ http://issues.apache.org/jira/brows...236
2040 ]
Graham Dumpleton commented on MODPYTHON-107:
--------------------------------------------
For PSP, the generated code actually explicitly says not to flush the output
and so is okay in that respect. Unfortunately, the CONTENT_LENGTH output fi
lter does not in work with PSP.
The reason is that although each individual req.write() doesn't flush, the P
SP code itself does an explicit flush after running the generated page code.
exec code in global_scope
req.flush()
For it to work, the req.flush() call would have to be removed.
Removing this shouldn't cause any issues when mod_python.psp is used as the
handler, but it may or may not be noticeable where people use PSP.run() meth
od from a distinct handler. This is because output would no longer be flushe
d by PSP.run(). Frankly tho
ugh, I don't think anyone would notice as it will get flushed on any subsequ
ent write or when handler returns.
> mod_python.publisher shouldn't flush result when written.
> ---------------------------------------------------------
>
> Key: MODPYTHON-107
> URL: http://issues.apache.org/jira/browse/MODPYTHON-107
> Project: mod_python
> Type: Improvement
> Components: publisher
> Versions: 3.2
> Reporter: Graham Dumpleton
>
> In mod_python.publisher, the result returned from a published function is
returned as the content of the response after it has been converted to a str
ing, using:
> req.write(result)
> In doing this, the second argument of req.write() is defaulting to '1', wh
ich indicates that the output should be flushed immediately.
> This fact prevents an output filter like CONTENT_LENGTH being used in conj
unction with mod_python.publisher.
> This output filter will add a content length header to the response, but only if i
t is able to read the full content the first time the output filter is called. Becau
se the output is flushed at this point, the output filter isn't able to do that, as
it
gets called twice. The first time it gets called will be with the actual content, the second
time happens when the handler returns apache.OK and is effectively a null output call to fo
rce the output filter to be closed off.
> If instead the output is written as:
> req.write(result,0)
> the output will not be flushed immediately and instead will be output in o
ne call when apache.OK is returned. There is no loss of efficiency in doing
this and instead it will actually eliminate a redundant call into the output
filter.
> For further details of this issue see discussion in:
> http://www.mail-archive.com/python-...g/msg00951.html
> This makes one wander if there should be a configurable option for mod_python.psp
to tell it not to flush output as well so that CONTENT_LENGTH could be used in that
case as well. ???
[ Post a follow-up to this message ]
|