def HEAD(self, req): """HTTP HEAD request handler.""" if len(self.account_name) > constraints.MAX_ACCOUNT_NAME_LENGTH: resp = HTTPBadRequest(request=req) resp.body = 'Account name length of %d longer than %d' % \ (len(self.account_name), constraints.MAX_ACCOUNT_NAME_LENGTH) return resp resp = self.get_account_head_resp(req) _set_info_cache(self.app, req.environ, self.account_name, None, resp) if req.environ.get('swift_owner'): self.add_acls_from_sys_metadata(resp) else: for header in self.app.swift_owner_headers: resp.headers.pop(header, None) return resp
def HEAD(self, req): """Handle HTTP GET or HEAD requests.""" container_info = self.container_info(self.account_name, self.container_name, req) req.acl = container_info['read_acl'] if 'swift.authorize' in req.environ: aresp = req.environ['swift.authorize'](req) if aresp: return aresp resp = self.get_object_head_resp(req) _set_info_cache(self.app, req.environ, self.account_name, self.container_name, resp) _set_object_info_cache(self.app, req.environ, self.account_name, self.container_name, self.object_name, resp) if ';' in resp.headers.get('content-type', ''): resp.content_type = clean_content_type( resp.headers['content-type']) return resp
def HEAD(self, req): """Handler for HTTP HEAD requests.""" if not self.account_info(self.account_name, req): if 'swift.authorize' in req.environ: aresp = req.environ['swift.authorize'](req) if aresp: return aresp return HTTPNotFound(request=req) resp = self.get_container_head_resp(req) _set_info_cache(self.app, req.environ, self.account_name, self.container_name, resp) if 'swift.authorize' in req.environ: req.acl = resp.headers.get('x-container-read') aresp = req.environ['swift.authorize'](req) if aresp: return aresp if not req.environ.get('swift_owner', False): for key in self.app.swift_owner_headers: if key in resp.headers: del resp.headers[key] return resp