def manifest_0(self, *tokens):
"""The request is an encoded pkg FMRI. If the version is
specified incompletely, we return an error, as the client is
expected to form correct requests based on its interpretation
of the catalog and its image policies."""
try:
pubs = self.repo.publishers
except Exception as e:
cherrypy.log("Request failed: {0}".format(e))
raise cherrypy.HTTPError(http_client.BAD_REQUEST, str(e))
# A broken proxy (or client) has caused a fully-qualified FMRI
# to be split up.
comps = [t for t in tokens]
if not comps:
raise cherrypy.HTTPError(http_client.FORBIDDEN,
_("Directory listing not allowed."))
if len(comps) > 1 and comps[0] == "pkg:" and comps[1] in pubs:
# Only one slash here as another will be added below.
comps[0] += "/"
# Parse request into FMRI component and decode.
try:
# If more than one token (request path component) was
# specified, assume that the extra components are part
# of the fmri and have been split out because of bad
# proxy behaviour.
pfmri = "/".join(comps)
pfmri = fmri.PkgFmri(pfmri, None)
fpath = self.repo.manifest(pfmri,
pub=self._get_req_pub())
except (IndexError, fmri.FmriError) as e:
raise cherrypy.HTTPError(http_client.BAD_REQUEST, str(e))
except srepo.RepositoryError as e:
# Treat any remaining repository error as a 404, but
# log the error and include the real failure
# information.
cherrypy.log("Request failed: {0}".format(str(e)))
raise cherrypy.HTTPError(http_client.NOT_FOUND, str(e))
# Send manifest
self.__set_response_expires("manifest", 86400*365, 86400*365)
return serve_file(fpath, "text/plain; charset=utf-8")
评论列表
文章目录