From f216f1b4f289957cda6c68f40586a462c384d3cb Mon Sep 17 00:00:00 2001 From: "Alric J. Althoff" Date: Wed, 11 Jul 2012 11:29:29 +0900 Subject: [PATCH] fix HEAD request incompatible HEAD requests to S3 respond with the exact same header as a GET, swift3 responds with an incorrect Content-Type and Content-Length. A quick hack to fix this issue is below, but should probably be replaced with something involving DiskFile and such from Swift's API, because of innecessary overhead involved in reading in the file. Signed-off-by: FUJITA Tomonori --- swift3/middleware.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/swift3/middleware.py b/swift3/middleware.py index 6acd744e..ec6a2d67 100644 --- a/swift3/middleware.py +++ b/swift3/middleware.py @@ -331,7 +331,17 @@ class ObjectController(WSGIContext): object_name) def GETorHEAD(self, env, start_response): + if env['REQUEST_METHOD'] == 'HEAD': + head = True + env['REQUEST_METHOD'] = 'GET' + else: + head = False + app_iter = self._app_call(env) + + if head: + app_iter = None + status = self._get_status_int() headers = dict(self._response_headers)