Refactor FormPost to use WSGIContext
... instead of self-handling subrequests manually. Closes-Bug: #1523401 Change-Id: I85b5302c2416de1793599385b791fcd3ec3b4da0
This commit is contained in:
@@ -138,7 +138,7 @@ from swift.common.utils import streq_const_time, parse_content_disposition, \
|
|||||||
parse_mime_headers, iter_multipart_mime_documents, reiterate, \
|
parse_mime_headers, iter_multipart_mime_documents, reiterate, \
|
||||||
closing_if_possible, get_logger
|
closing_if_possible, get_logger
|
||||||
from swift.common.registry import register_swift_info
|
from swift.common.registry import register_swift_info
|
||||||
from swift.common.wsgi import make_pre_authed_env
|
from swift.common.wsgi import WSGIContext, make_pre_authed_env
|
||||||
from swift.common.swob import HTTPUnauthorized, wsgi_to_str, str_to_wsgi
|
from swift.common.swob import HTTPUnauthorized, wsgi_to_str, str_to_wsgi
|
||||||
from swift.common.http import is_success
|
from swift.common.http import is_success
|
||||||
from swift.proxy.controllers.base import get_account_info, get_container_info
|
from swift.proxy.controllers.base import get_account_info, get_container_info
|
||||||
@@ -438,25 +438,14 @@ class FormPost(object):
|
|||||||
if not has_valid_sig:
|
if not has_valid_sig:
|
||||||
raise FormUnauthorized('invalid signature')
|
raise FormUnauthorized('invalid signature')
|
||||||
self.logger.increment('formpost.digests.%s' % hash_name)
|
self.logger.increment('formpost.digests.%s' % hash_name)
|
||||||
|
wsgi_ctx = WSGIContext(self.app)
|
||||||
substatus = [None]
|
|
||||||
subheaders = [None]
|
|
||||||
|
|
||||||
wsgi_input = subenv['wsgi.input']
|
wsgi_input = subenv['wsgi.input']
|
||||||
|
resp = wsgi_ctx._app_call(subenv)
|
||||||
def _start_response(status, headers, exc_info=None):
|
|
||||||
if wsgi_input.file_size_exceeded:
|
if wsgi_input.file_size_exceeded:
|
||||||
raise EOFError("max_file_size exceeded")
|
raise EOFError("max_file_size exceeded")
|
||||||
|
|
||||||
substatus[0] = status
|
|
||||||
subheaders[0] = headers
|
|
||||||
|
|
||||||
# reiterate to ensure the response started,
|
|
||||||
# but drop any data on the floor
|
|
||||||
resp = self.app(subenv, _start_response)
|
|
||||||
with closing_if_possible(reiterate(resp)):
|
with closing_if_possible(reiterate(resp)):
|
||||||
body = b''.join(resp)
|
body = b''.join(resp)
|
||||||
return substatus[0], subheaders[0], body
|
return wsgi_ctx._response_status, wsgi_ctx._response_headers, body
|
||||||
|
|
||||||
def _get_keys(self, env):
|
def _get_keys(self, env):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user