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))
# NASTY
# Stash manifest entry for later use.
# Toss out the list if it's larger than 1024 items.
if len(self.requested_manifests) > 1024:
self.requested_manifests = [fpath]
else:
self.requested_manifests.append(fpath)
# NASTY
# Send the wrong manifest
if self.need_nasty_3():
cherrypy.log("NASTY manifest_0: serve wrong mfst")
badpath = random.choice(self.requested_manifests)
return serve_file(badpath, "text/plain; charset=utf-8")
# NASTY
# Call a misbehaving serve_file
return self.nasty_serve_file(fpath, "text/plain; charset=utf-8")
评论列表
文章目录