On Mon, 2 Jan 2006, Graham Dumpleton (JIRA) wrote:
In addressing MODPYTHON-71, mod_python.publisher code was changed to read:
if req.method!='HEAD':
req.write(result)
This change should not really have been made and it should be changed
back to what was there before, ie., just:
req.write(result)
[...]
As an an example of an Apache module that uses output filters to do
stuff, there is mod_cache. Luckily in that case, a HEAD request is one
of various cases where mod_cache decides it will not use the output.
This does not mean though that some other output filter that someone is
using might expect content to be there for HEAD.
I am not sure I agree with this explanation (while I do agree that the
behaviour should be reverted, but for different reason, see below). The
RFC is pretty clear on HEAD: "The HEAD method is identical to GET except
that the server MUST NOT return a message-body in the response.", so for a
filter (or anything) to expect the content with HEAD is wrong.
In summary, one could also say that if a user wants to not output
anything for a HEAD request, that is there decision, but
mod_python.publisher should not be making that decision for them.
May be not for the publisher, but given the "MUST NOT" it should be OK for
either httpd or mod_python to do this. If httpd does not do it, then
perhaps it should be made part of req.write()? It may be a good idea to
check the httpd-dev archives to see if the issue of HEAD has been
discussed in the past.
In any event, I think the behaviour should be reverted to ignore HEAD for
now simply because it is a half-ass solution given that req.write() gets
through, especially because PSP templates rely on req.write() primarily.
I think for 3.2 we can just leave it at that, but for 3.3 to seriously
consider whether mod_python should chop output for HEAD requests.
Also, I think a link to this JIRA issue as a comment somewhere in the code
would be great or someone down the road will repeat this whole HEAD thing
again.
Grisha