本文整理汇总了Python中swift.common.middleware.bulk.get_response_body函数的典型用法代码示例。如果您正苦于以下问题:Python get_response_body函数的具体用法?Python get_response_body怎么用?Python get_response_body使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_response_body函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_response_body
def test_get_response_body(self):
txt_body = bulk.get_response_body(
'bad_formay', {'hey': 'there'}, [['json > xml', '202 Accepted']])
self.assert_('hey: there' in txt_body)
xml_body = bulk.get_response_body(
'text/xml', {'hey': 'there'}, [['json > xml', '202 Accepted']])
self.assert_('>' in xml_body)
开发者ID:2015-ucsc-hp,项目名称:swift,代码行数:7,代码来源:test_bulk.py
示例2: test_get_response_body
def test_get_response_body(self):
txt_body = bulk.get_response_body(
'bad_formay', {'hey': 'there'}, [['json > xml', '202 Accepted']],
"doesn't matter for text")
self.assertTrue('hey: there' in txt_body)
xml_body = bulk.get_response_body(
'text/xml', {'hey': 'there'}, [['json > xml', '202 Accepted']],
'root_tag')
self.assertTrue('>' in xml_body)
self.assertTrue(xml_body.startswith('<root_tag>\n'))
self.assertTrue(xml_body.endswith('\n</root_tag>\n'))
开发者ID:chenzhongtao,项目名称:swift,代码行数:11,代码来源:test_bulk.py
示例3: handle_multipart_put
#.........这里部分代码省略.........
new_env = req.environ.copy()
new_env['PATH_INFO'] = obj_path
new_env['REQUEST_METHOD'] = 'HEAD'
new_env['swift.source'] = 'SLO'
del(new_env['wsgi.input'])
del(new_env['QUERY_STRING'])
new_env['CONTENT_LENGTH'] = 0
new_env['HTTP_USER_AGENT'] = \
'%s MultipartPUT' % req.environ.get('HTTP_USER_AGENT')
if obj_path != last_obj_path:
last_obj_path = obj_path
head_seg_resp = \
Request.blank(obj_path, new_env).get_response(self)
if head_seg_resp.is_success:
segment_length = head_seg_resp.content_length
if seg_dict.get('range'):
# Since we now know the length, we can normalize the
# range. We know that there is exactly one range
# requested since we checked that earlier in
# parse_and_validate_input().
ranges = seg_dict['range'].ranges_for_length(
head_seg_resp.content_length)
if not ranges:
problem_segments.append([quote(obj_name),
'Unsatisfiable Range'])
elif ranges == [(0, head_seg_resp.content_length)]:
# Just one range, and it exactly matches the object.
# Why'd we do this again?
del seg_dict['range']
segment_length = head_seg_resp.content_length
else:
rng = ranges[0]
seg_dict['range'] = '%d-%d' % (rng[0], rng[1] - 1)
segment_length = rng[1] - rng[0]
if segment_length < self.min_segment_size and \
index < len(parsed_data) - 1:
problem_segments.append(
[quote(obj_name),
'Too small; each segment, except the last, must be '
'at least %d bytes.' % self.min_segment_size])
total_size += segment_length
if seg_dict['size_bytes'] is not None and \
seg_dict['size_bytes'] != head_seg_resp.content_length:
problem_segments.append([quote(obj_name), 'Size Mismatch'])
if seg_dict['etag'] is None or \
seg_dict['etag'] == head_seg_resp.etag:
if seg_dict.get('range'):
slo_etag.update('%s:%s;' % (head_seg_resp.etag,
seg_dict['range']))
else:
slo_etag.update(head_seg_resp.etag)
else:
problem_segments.append([quote(obj_name), 'Etag Mismatch'])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
# shouldn't happen
last_modified = datetime.now()
last_modified_formatted = \
last_modified.strftime('%Y-%m-%dT%H:%M:%S.%f')
seg_data = {'name': '/' + seg_dict['path'].lstrip('/'),
'bytes': head_seg_resp.content_length,
'hash': head_seg_resp.etag,
'content_type': head_seg_resp.content_type,
'last_modified': last_modified_formatted}
if seg_dict.get('range'):
seg_data['range'] = seg_dict['range']
if config_true_value(
head_seg_resp.headers.get('X-Static-Large-Object')):
seg_data['sub_slo'] = True
data_for_storage.append(seg_data)
else:
problem_segments.append([quote(obj_name),
head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(
out_content_type, {}, problem_segments)
raise HTTPBadRequest(resp_body, content_type=out_content_type)
env = req.environ
if not env.get('CONTENT_TYPE'):
guessed_type, _junk = mimetypes.guess_type(req.path_info)
env['CONTENT_TYPE'] = guessed_type or 'application/octet-stream'
env['swift.content_type_overridden'] = True
env['CONTENT_TYPE'] += ";swift_bytes=%d" % total_size
env['HTTP_X_STATIC_LARGE_OBJECT'] = 'True'
json_data = json.dumps(data_for_storage)
if six.PY3:
json_data = json_data.encode('utf-8')
env['CONTENT_LENGTH'] = str(len(json_data))
env['wsgi.input'] = BytesIO(json_data)
slo_put_context = SloPutContext(self, slo_etag)
return slo_put_context.handle_slo_put(req, start_response)
开发者ID:iloveyou416068,项目名称:swift-1,代码行数:101,代码来源:slo.py
示例4: handle_multipart_put
def handle_multipart_put(self, req):
"""
Will handle the PUT of a SLO manifest.
Heads every object in manifest to check if is valid and if so will
save a manifest generated from the user input.
:params req: a swob.Request with an obj in path
:raises: HttpException on errors
"""
try:
vrs, account, container, obj = req.split_path(1, 4, True)
except ValueError:
return self.app
if req.content_length > self.max_manifest_size:
raise HTTPRequestEntityTooLarge(
"Manifest File > %d bytes" % self.max_manifest_size)
if req.headers.get('X-Copy-From'):
raise HTTPMethodNotAllowed(
'Multipart Manifest PUTs cannot be Copy requests')
if req.content_length is None and \
req.headers.get('transfer-encoding', '').lower() != 'chunked':
raise HTTPLengthRequired(request=req)
parsed_data = parse_input(req.body_file.read(self.max_manifest_size))
problem_segments = []
if len(parsed_data) > self.max_manifest_segments:
raise HTTPRequestEntityTooLarge(
'Number segments must be <= %d' % self.max_manifest_segments)
total_size = 0
out_content_type = req.accept.best_match(ACCEPTABLE_FORMATS)
if not out_content_type:
out_content_type = 'text/plain'
data_for_storage = []
for index, seg_dict in enumerate(parsed_data):
obj_path = '/'.join(
['', vrs, account, seg_dict['path'].lstrip('/')])
try:
seg_size = int(seg_dict['size_bytes'])
except (ValueError, TypeError):
raise HTTPBadRequest('Invalid Manifest File')
if seg_size < self.min_segment_size and \
(index == 0 or index < len(parsed_data) - 1):
raise HTTPBadRequest(
'Each segment, except the last, must be larger than '
'%d bytes.' % self.min_segment_size)
new_env = req.environ.copy()
if isinstance(obj_path, unicode):
obj_path = obj_path.encode('utf-8')
new_env['PATH_INFO'] = obj_path
new_env['REQUEST_METHOD'] = 'HEAD'
new_env['swift.source'] = 'SLO'
del(new_env['wsgi.input'])
del(new_env['QUERY_STRING'])
new_env['CONTENT_LENGTH'] = 0
new_env['HTTP_USER_AGENT'] = \
'%s MultipartPUT' % req.environ.get('HTTP_USER_AGENT')
head_seg_resp = \
Request.blank(obj_path, new_env).get_response(self.app)
if head_seg_resp.status_int // 100 == 2:
total_size += seg_size
if seg_size != head_seg_resp.content_length:
problem_segments.append([quote(obj_path), 'Size Mismatch'])
if seg_dict['etag'] != head_seg_resp.etag:
problem_segments.append([quote(obj_path), 'Etag Mismatch'])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
# shouldn't happen
last_modified = datetime.now()
last_modified_formatted = \
last_modified.strftime('%Y-%m-%dT%H:%M:%S.%f')
data_for_storage.append(
{'name': '/' + seg_dict['path'].lstrip('/'),
'bytes': seg_size,
'hash': seg_dict['etag'],
'content_type': head_seg_resp.content_type,
'last_modified': last_modified_formatted})
else:
problem_segments.append([quote(obj_path),
head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(
out_content_type, {}, problem_segments)
raise HTTPBadRequest(resp_body, content_type=out_content_type)
env = req.environ
if not env.get('CONTENT_TYPE'):
guessed_type, _junk = mimetypes.guess_type(req.path_info)
env['CONTENT_TYPE'] = guessed_type or 'application/octet-stream'
env['swift.content_type_overriden'] = True
env['CONTENT_TYPE'] += ";swift_bytes=%d" % total_size
env['HTTP_X_STATIC_LARGE_OBJECT'] = 'True'
json_data = json.dumps(data_for_storage)
env['CONTENT_LENGTH'] = str(len(json_data))
env['wsgi.input'] = StringIO(json_data)
return self.app
开发者ID:GoodDingo,项目名称:openstack-swift,代码行数:99,代码来源:slo.py
示例5: test_get_response_body
def test_get_response_body(self):
txt_body = bulk.get_response_body("bad_formay", {"hey": "there"}, [["json > xml", "202 Accepted"]])
self.assert_("hey: there" in txt_body)
xml_body = bulk.get_response_body("text/xml", {"hey": "there"}, [["json > xml", "202 Accepted"]])
self.assert_(">" in xml_body)
开发者ID:JioCloud,项目名称:swift,代码行数:5,代码来源:test_bulk.py
示例6: handle_multipart_put
#.........这里部分代码省略.........
# Since we now know the length, we can normalize the
# range. We know that there is exactly one range
# requested since we checked that earlier in
# parse_and_validate_input().
ranges = seg_dict['range'].ranges_for_length(
head_seg_resp.content_length)
if not ranges:
problem_segments.append([quote(obj_name),
'Unsatisfiable Range'])
elif ranges == [(0, head_seg_resp.content_length)]:
# Just one range, and it exactly matches the object.
# Why'd we do this again?
del seg_dict['range']
segment_length = head_seg_resp.content_length
else:
rng = ranges[0]
seg_dict['range'] = '%d-%d' % (rng[0], rng[1] - 1)
segment_length = rng[1] - rng[0]
if segment_length < 1:
problem_segments.append(
[quote(obj_name),
'Too small; each segment must be at least 1 byte.'])
if seg_dict.get('size_bytes') is not None and \
seg_dict['size_bytes'] != head_seg_resp.content_length:
problem_segments.append([quote(obj_name), 'Size Mismatch'])
if seg_dict.get('etag') is not None and \
seg_dict['etag'] != head_seg_resp.etag:
problem_segments.append([quote(obj_name), 'Etag Mismatch'])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
# shouldn't happen
last_modified = datetime.now()
last_modified_formatted = \
last_modified.strftime('%Y-%m-%dT%H:%M:%S.%f')
seg_data = {'name': '/' + seg_dict['path'].lstrip('/'),
'bytes': head_seg_resp.content_length,
'hash': head_seg_resp.etag,
'content_type': head_seg_resp.content_type,
'last_modified': last_modified_formatted}
if seg_dict.get('range'):
seg_data['range'] = seg_dict['range']
if config_true_value(
head_seg_resp.headers.get('X-Static-Large-Object')):
seg_data['sub_slo'] = True
return segment_length, seg_data
data_for_storage = [None] * len(parsed_data)
with StreamingPile(self.concurrency) as pile:
for obj_name, resp in pile.asyncstarmap(do_head, (
(path, ) for path in path2indices)):
for i in path2indices[obj_name]:
segment_length, seg_data = validate_seg_dict(
parsed_data[i], resp)
data_for_storage[i] = seg_data
total_size += segment_length
if problem_segments:
resp_body = get_response_body(
out_content_type, {}, problem_segments)
raise HTTPBadRequest(resp_body, content_type=out_content_type)
slo_etag = md5()
for seg_data in data_for_storage:
if seg_data.get('range'):
slo_etag.update('%s:%s;' % (seg_data['hash'],
seg_data['range']))
else:
slo_etag.update(seg_data['hash'])
slo_etag = slo_etag.hexdigest()
req.headers.update({
SYSMETA_SLO_ETAG: slo_etag,
SYSMETA_SLO_SIZE: total_size,
'X-Static-Large-Object': 'True',
})
json_data = json.dumps(data_for_storage)
if six.PY3:
json_data = json_data.encode('utf-8')
req.body = json_data
env = req.environ
if not env.get('CONTENT_TYPE'):
guessed_type, _junk = mimetypes.guess_type(req.path_info)
env['CONTENT_TYPE'] = guessed_type or 'application/octet-stream'
env['swift.content_type_overridden'] = True
env['CONTENT_TYPE'] += ";swift_bytes=%d" % total_size
def start_response_wrapper(status, headers, exc_info=None):
for i, (header, _value) in enumerate(headers):
if header.lower() == 'etag':
headers[i] = ('Etag', '"%s"' % slo_etag)
break
return start_response(status, headers, exc_info)
return self.app(env, start_response_wrapper)
开发者ID:bebule,项目名称:swift,代码行数:101,代码来源:slo.py
示例7: test_get_response_body
def test_get_response_body(self):
self.assertRaises(
HTTPException, bulk.get_response_body, 'badformat', {}, [])
xml_body = bulk.get_response_body(
'text/xml', {'hey': 'there'}, [['json > xml', '202 Accepted']])
self.assert_('>' in xml_body)
开发者ID:jiongpan,项目名称:swift,代码行数:6,代码来源:test_bulk.py
示例8: handle_multipart_put
def handle_multipart_put(self, req):
try:
vrs, account, container, obj = split_path(req.path,1, 4, True)
except ValueError:
return self.app
if req.content_length > self.max_manifest_size:
raise HTTPRequestEntityTooLarge(
"Manifest File > %d bytes" % self.max_manifest_size)
if req.headers.get('X-Copy-From') or req.headers.get('Destination'):
raise HTTPMethodNotAllowed(
'Multipart Manifest PUTs cannot be Copy requests')
if req.content_length is None and \
req.headers.get('transfer-encoding', '').lower() != 'chunked':
raise HTTPLengthRequired(request=req)
parsed_data = parse_input(req.environ['wsgi.input'].read(self.max_manifest_size))
problem_segments = []
if len(parsed_data) > self.max_manifest_segments:
raise HTTPRequestEntityTooLarge(
'Number segments must be <= %d' % self.max_manifest_segments)
total_size = 0
out_content_type = 'application/json'
if not out_content_type:
out_content_type = 'text/plain'
data_for_storage = []
for index, seg_dict in enumerate(parsed_data):
obj_path = '/'.join(
['', vrs, account, seg_dict['path'].lstrip('/')])
try:
seg_size = int(seg_dict['size_bytes'])
except (ValueError, TypeError):
raise HTTPBadRequest('Invalid Manifest File')
new_env = req.environ.copy()
if isinstance(obj_path, unicode):
obj_path = obj_path.encode('utf-8')
new_env['PATH_INFO'] = obj_path
new_env['REQUEST_METHOD'] = 'HEAD'
new_env['swift.source'] = 'SLO'
del(new_env['wsgi.input'])
del(new_env['QUERY_STRING'])
new_env['CONTENT_LENGTH'] = 0
new_env['HTTP_USER_AGENT'] = \
'%s MultipartPUT' % req.environ.get('HTTP_USER_AGENT')
head_seg_resp = \
Request.blank(obj_path, new_env).get_response(self.app)
if head_seg_resp.status_int // 100 == 2:
total_size += seg_size
if seg_size != head_seg_resp.content_length:
problem_segments.append([quote(obj_path), 'Size Mismatch'])
if seg_dict['etag'] != head_seg_resp.etag:
problem_segments.append([quote(obj_path), 'Etag Mismatch'])
data_for_storage.append(
{'name': '/' + seg_dict['path'].lstrip('/'),
'bytes': seg_size,
'hash': seg_dict['etag']})
else:
problem_segments.append([quote(obj_path),
head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(
out_content_type, {}, problem_segments)
raise jresponse('-1','badrequest',req,400,param=resp_body)
env = req.environ
env['swift.content_type_overriden'] = True
env['HTTP_X_STATIC_LARGE_OBJECT'] = 'True'
json_data = json.dumps(data_for_storage)
env['CONTENT_LENGTH'] = str(len(json_data))
env['wsgi.input'] = StringIO(json_data)
return self.app
开发者ID:sun3shines,项目名称:swift-1.7.4,代码行数:79,代码来源:slo.py
示例9: handle_multipart_put
#.........这里部分代码省略.........
try:
seg_size = int(seg_dict["size_bytes"])
except (ValueError, TypeError):
if seg_dict["size_bytes"] is None:
seg_size = None
else:
raise HTTPBadRequest("Invalid Manifest File")
if seg_size is not None and seg_size < self.min_segment_size and index < len(parsed_data) - 1:
raise HTTPBadRequest(
"Each segment, except the last, must be at least " "%d bytes." % self.min_segment_size
)
new_env = req.environ.copy()
new_env["PATH_INFO"] = obj_path
new_env["REQUEST_METHOD"] = "HEAD"
new_env["swift.source"] = "SLO"
del (new_env["wsgi.input"])
del (new_env["QUERY_STRING"])
new_env["CONTENT_LENGTH"] = 0
new_env["HTTP_USER_AGENT"] = "%s MultipartPUT" % req.environ.get("HTTP_USER_AGENT")
if obj_path != last_obj_path:
last_obj_path = obj_path
head_seg_resp = Request.blank(obj_path, new_env).get_response(self)
if head_seg_resp.is_success:
segment_length = head_seg_resp.content_length
if seg_dict.get("range"):
# Since we now know the length, we can normalize the ranges
ranges = seg_dict["range"].ranges_for_length(head_seg_resp.content_length)
if not ranges:
problem_segments.append([quote(obj_name), "Unsatisfiable Range"])
elif len(ranges) > 1:
problem_segments.append([quote(obj_name), "Multiple Ranges"])
elif ranges == [(0, head_seg_resp.content_length)]:
# Just one range, and it exactly matches the object.
# Why'd we do this again?
seg_dict["range"] = None
segment_length = head_seg_resp.content_length
else:
range = ranges[0]
seg_dict["range"] = "%d-%d" % (range[0], range[1] - 1)
segment_length = range[1] - range[0]
if segment_length < self.min_segment_size and index < len(parsed_data) - 1:
raise HTTPBadRequest(
"Each segment, except the last, must be at least " "%d bytes." % self.min_segment_size
)
total_size += segment_length
if seg_size is not None and seg_size != head_seg_resp.content_length:
problem_segments.append([quote(obj_name), "Size Mismatch"])
if seg_dict["etag"] is None or seg_dict["etag"] == head_seg_resp.etag:
if seg_dict.get("range"):
slo_etag.update("%s:%s;" % (head_seg_resp.etag, seg_dict["range"]))
else:
slo_etag.update(head_seg_resp.etag)
else:
problem_segments.append([quote(obj_name), "Etag Mismatch"])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
# shouldn't happen
last_modified = datetime.now()
last_modified_formatted = last_modified.strftime("%Y-%m-%dT%H:%M:%S.%f")
seg_data = {
"name": "/" + seg_dict["path"].lstrip("/"),
"bytes": head_seg_resp.content_length,
"hash": head_seg_resp.etag,
"content_type": head_seg_resp.content_type,
"last_modified": last_modified_formatted,
}
if seg_dict.get("range"):
seg_data["range"] = seg_dict["range"]
if config_true_value(head_seg_resp.headers.get("X-Static-Large-Object")):
seg_data["sub_slo"] = True
data_for_storage.append(seg_data)
else:
problem_segments.append([quote(obj_name), head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(out_content_type, {}, problem_segments)
raise HTTPBadRequest(resp_body, content_type=out_content_type)
env = req.environ
if not env.get("CONTENT_TYPE"):
guessed_type, _junk = mimetypes.guess_type(req.path_info)
env["CONTENT_TYPE"] = guessed_type or "application/octet-stream"
env["swift.content_type_overridden"] = True
env["CONTENT_TYPE"] += ";swift_bytes=%d" % total_size
env["HTTP_X_STATIC_LARGE_OBJECT"] = "True"
json_data = json.dumps(data_for_storage)
if six.PY3:
json_data = json_data.encode("utf-8")
env["CONTENT_LENGTH"] = str(len(json_data))
env["wsgi.input"] = BytesIO(json_data)
slo_put_context = SloPutContext(self, slo_etag)
return slo_put_context.handle_slo_put(req, start_response)
开发者ID:pchng,项目名称:swift,代码行数:101,代码来源:slo.py
示例10: test_get_response_body
def test_get_response_body(self):
self.assertRaises(HTTPException, bulk.get_response_body, "badformat", {}, [])
xml_body = bulk.get_response_body("text/xml", {"hey": "there"}, [["json > xml", "202 Accepted"]])
self.assert_(">" in xml_body)
开发者ID:adrian,项目名称:swift,代码行数:4,代码来源:test_bulk.py
示例11: handle_multipart_put
def handle_multipart_put(self, req):
"""
Will handle the PUT of a SLO manifest.
Heads every object in manifest to check if is valid and if so will
save a manifest generated from the user input.
:params req: a swob.Request with an obj in path
:raises: HttpException on errors
"""
try:
vrs, account, container, obj = req.split_path(1, 4, True)
except ValueError:
return self.app
if req.content_length > self.max_manifest_size:
raise HTTPRequestEntityTooLarge("Manifest File > %d bytes" % self.max_manifest_size)
if req.headers.get("X-Copy-From"):
raise HTTPMethodNotAllowed("Multipart Manifest PUTs cannot be Copy requests")
if req.content_length is None and req.headers.get("transfer-encoding", "").lower() != "chunked":
raise HTTPLengthRequired(request=req)
parsed_data = parse_input(req.body_file.read(self.max_manifest_size))
problem_segments = []
if len(parsed_data) > self.max_manifest_segments:
raise HTTPRequestEntityTooLarge("Number segments must be <= %d" % self.max_manifest_segments)
total_size = 0
out_content_type = req.accept.best_match(ACCEPTABLE_FORMATS)
if not out_content_type:
out_content_type = "text/plain"
data_for_storage = []
for index, seg_dict in enumerate(parsed_data):
obj_path = "/".join(["", vrs, account, seg_dict["path"].lstrip("/")])
try:
seg_size = int(seg_dict["size_bytes"])
except (ValueError, TypeError):
raise HTTPBadRequest("Invalid Manifest File")
if seg_size < self.min_segment_size and (index == 0 or index < len(parsed_data) - 1):
raise HTTPBadRequest(
"Each segment, except the last, must be larger than " "%d bytes." % self.min_segment_size
)
new_env = req.environ.copy()
if isinstance(obj_path, unicode):
obj_path = obj_path.encode("utf-8")
new_env["PATH_INFO"] = obj_path
new_env["REQUEST_METHOD"] = "HEAD"
new_env["swift.source"] = "SLO"
del (new_env["wsgi.input"])
del (new_env["QUERY_STRING"])
new_env["CONTENT_LENGTH"] = 0
new_env["HTTP_USER_AGENT"] = "%s MultipartPUT" % req.environ.get("HTTP_USER_AGENT")
head_seg_resp = Request.blank(obj_path, new_env).get_response(self.app)
if head_seg_resp.is_success:
total_size += seg_size
if seg_size != head_seg_resp.content_length:
problem_segments.append([quote(obj_path), "Size Mismatch"])
if seg_dict["etag"] != head_seg_resp.etag:
problem_segments.append([quote(obj_path), "Etag Mismatch"])
if head_seg_resp.last_modified:
last_modified = head_seg_resp.last_modified
else:
# shouldn't happen
last_modified = datetime.now()
last_modified_formatted = last_modified.strftime("%Y-%m-%dT%H:%M:%S.%f")
seg_data = {
"name": "/" + seg_dict["path"].lstrip("/"),
"bytes": seg_size,
"hash": seg_dict["etag"],
"content_type": head_seg_resp.content_type,
"last_modified": last_modified_formatted,
}
if config_true_value(head_seg_resp.headers.get("X-Static-Large-Object")):
seg_data["sub_slo"] = True
data_for_storage.append(seg_data)
else:
problem_segments.append([quote(obj_path), head_seg_resp.status])
if problem_segments:
resp_body = get_response_body(out_content_type, {}, problem_segments)
raise HTTPBadRequest(resp_body, content_type=out_content_type)
env = req.environ
if not env.get("CONTENT_TYPE"):
guessed_type, _junk = mimetypes.guess_type(req.path_info)
env["CONTENT_TYPE"] = guessed_type or "application/octet-stream"
env["swift.content_type_overriden"] = True
env["CONTENT_TYPE"] += ";swift_bytes=%d" % total_size
env["HTTP_X_STATIC_LARGE_OBJECT"] = "True"
json_data = json.dumps(data_for_storage)
env["CONTENT_LENGTH"] = str(len(json_data))
env["wsgi.input"] = StringIO(json_data)
return self.app
开发者ID:GitFloki,项目名称:Shake,代码行数:92,代码来源:slo.py
注:本文中的swift.common.middleware.bulk.get_response_body函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论