I'm receiving HEAD requests in my application, and wondering on the best way to handle them. Options are:
- convert them to GETs, process GET normally, then:
- strip the body (though I'm not sure how -
response.content = ''
doesn't seem to do it. - it seems app engine auto-strips the body, giving a warning "Dropping unexpected body in response to HEAD request"
- strip the body (though I'm not sure how -
It seems this is clean, and can be written nicely using decorators or middleware.
- Handle each HEAD request specially:
- this means I could avoid a DataStore access in some (many?) cases.
- There is a risk, apparently, that middleware which sets the Content-length header will be prevented from doing so by this approach.
Anything else? Which should I do? Does using App Engine make a difference here? Are there subtle details; if so, is there appropriate middleware to use? To convert to GET, is `request.method = "GET" sufficient (it seems to work)?