0

I'm managing an old django (1.4) application where the following is happening.

In a function based view I receive a request, if it is a HEAD method then I just reply with an empty response

if request.method == 'HEAD':
    return HttpResponse()

This is just a simple method to check that the client (a script) has a correct configuration and the url is correct.

Otherwise, if method is GET then proceed inside then view.

This work in a local django debug server.
When I deploy this behind Apache and wsgi, something is transforming my http HEAD method in GET.

In the apache log I see that it correctly receives a HEAD method but then in my django application the same request is received as GET!

Can Apache or wsgi be responsible for this? Where should I look for additional clues?

Leonardo
  • 4,046
  • 5
  • 44
  • 85
  • [This answer](https://stackoverflow.com/questions/22443245/why-does-apache-wsgi-map-head-to-get-how-to-speed-up-head-in-flask) and the [linked blogpost](http://blog.dscpl.com.au/2009/10/wsgi-issues-with-http-head-requests.html) might help. – Alasdair Sep 26 '17 at 14:54
  • 1
    I confirm that it is indeed mod_wsgi that does this. I haven't a solution for this but a workaround. I've changed the logic of my view and always assume the request is GET. Then when I pass a special param (for example `url?exist=true`) I handle that requests as if it was a HEAD. – Leonardo Sep 28 '17 at 15:12

0 Answers0