[web] Fix HEAD request handling (closes #3677949)
Don't special-case HEAD in CubicWebRequestBase.is_client_cache_valid so
we don't return garbage. HEAD is supposed to return the actual headers
that a GET would return, which we can't do if we bypass all the normal
cubicweb logic. In particular, we no longer always return 200, and
return the right Content-Length/Content-Type/...
--- a/web/request.py Tue Apr 08 16:12:39 2014 +0200
+++ b/web/request.py Mon Mar 24 10:34:58 2014 +0100
@@ -769,10 +769,6 @@
if 'Expires' not in self.headers_out:
# Expires header seems to be required by IE7 -- Are you sure ?
self.add_header('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT')
- if self.http_method() == 'HEAD':
- self.status_out = 200
- # XXX replace by True once validate_cache bw compat method is dropped
- return 200
# /!\ no raise, the function returns and we keep processing the request
else:
# overwrite headers_out to forge a brand new not-modified response
--- a/web/test/unittest_http.py Tue Apr 08 16:12:39 2014 +0200
+++ b/web/test/unittest_http.py Mon Mar 24 10:34:58 2014 +0100
@@ -227,7 +227,7 @@
hout = [('etag', 'rhino/really-not-babar'),
]
req = _test_cache(hin, hout, method='HEAD')
- self.assertCache(200, req.status_out, 'modifier HEAD verb')
+ self.assertCache(None, req.status_out, 'modifier HEAD verb')
# not modified
hin = [('if-none-match', 'babar'),
]