예제 #1
0
 def __call__(self, env, start_response):
     ctx = WSGIContext(self.app)
     app_iter = ctx._app_call(env)
     try:
         split_path(env['PATH_INFO'], 4, 4, True)
     except ValueError:
         pass  # not an object request; don't care
     else:
         if env['REQUEST_METHOD'] == 'DELETE' and \
                 ctx._response_status[:3] == '404':
             # Should be a cache hit
             if is_success(
                     get_container_info(env, self.app,
                                        swift_source='S3').get('status')):
                 # Convert to a successful response
                 ctx._response_status = '204 No Content'
                 ctx._response_headers = [
                     (h, '0' if h.lower() == 'content-length' else v)
                     for h, v in ctx._response_headers
                 ]
                 with closing_if_possible(app_iter):
                     for chunk in app_iter:
                         pass  # should be short; just drop it on the floor
                 app_iter = ['']
     start_response(ctx._response_status, ctx._response_headers)
     return app_iter