def __upload_manifest(self, *tokens):
"""Adds a file to an in-flight transaction for the Transaction
ID specified in the request path. The content is expected to be
in the request body. Returns no output."""
try:
# cherrypy decoded it, but we actually need it encoded.
trans_id = quote(tokens[0], "")
except IndexError:
raise
trans_id = None
request = cherrypy.request
response = cherrypy.response
size = int(request.headers.get("Content-Length", 0))
if size < 0:
raise cherrypy.HTTPError(http_client.BAD_REQUEST,
_("manifest/1 must be sent a file."))
data = request.rfile
try:
self.repo.add_manifest(trans_id, data)
except srepo.RepositoryError as e:
# Assume a bad request was made. A 404 can't be
# returned here as misc.versioned_urlopen will interpret
# that to mean that the server doesn't support this
# operation.
raise cherrypy.HTTPError(http_client.BAD_REQUEST, str(e))
response.headers["Content-Length"] = "0"
return response.body
评论列表
文章目录