diff --git a/swift/account/server.py b/swift/account/server.py index f15ac38c11..54f13177f5 100644 --- a/swift/account/server.py +++ b/swift/account/server.py @@ -261,7 +261,7 @@ class AccountController(object): if self.mount_check and not check_mount(self.root, drive): return Response(status='507 %s is not mounted' % drive) try: - args = simplejson.load(req.body_file) + args = simplejson.load(req.environ['wsgi.input']) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain') ret = self.replicator_rpc.dispatch(post_args, args) diff --git a/swift/container/server.py b/swift/container/server.py index 3601594afc..3ced13d61f 100644 --- a/swift/container/server.py +++ b/swift/container/server.py @@ -349,7 +349,7 @@ class ContainerController(object): if self.mount_check and not check_mount(self.root, drive): return Response(status='507 %s is not mounted' % drive) try: - args = simplejson.load(req.body_file) + args = simplejson.load(req.environ['wsgi.input']) except ValueError, err: return HTTPBadRequest(body=str(err), content_type='text/plain') ret = self.replicator_rpc.dispatch(post_args, args) diff --git a/swift/obj/server.py b/swift/obj/server.py index 9e95ec7c6f..7d4b433a01 100644 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -383,8 +383,8 @@ class ObjectController(object): with file.mkstemp() as (fd, tmppath): if 'content-length' in request.headers: fallocate(fd, int(request.headers['content-length'])) - for chunk in iter(lambda: request.body_file.read( - self.network_chunk_size), ''): + reader = request.environ['wsgi.input'].read + for chunk in iter(lambda: reader(self.network_chunk_size), ''): upload_size += len(chunk) if time.time() > upload_expiration: return HTTPRequestTimeout(request=request) diff --git a/swift/proxy/server.py b/swift/proxy/server.py index 0a0991c517..cdb6b335db 100644 --- a/swift/proxy/server.py +++ b/swift/proxy/server.py @@ -929,8 +929,8 @@ class ObjectController(Controller): error_response = check_object_creation(req, self.object_name) if error_response: return error_response - data_source = \ - iter(lambda: req.body_file.read(self.app.client_chunk_size), '') + reader = req.environ['wsgi.input'].read + data_source = iter(lambda: reader(self.app.client_chunk_size), '') source_header = req.headers.get('X-Copy-From') if source_header: source_header = unquote(source_header) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index babcf99eca..782a31d2c5 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -835,9 +835,9 @@ class TestObjectController(unittest.TestCase): def test_status_map(statuses, expected): self.app.memcache.store = {} proxy_server.http_connect = mock_http_connect(*statuses) - req = Request.blank('/a/c/o.jpg', {}) + req = Request.blank('/a/c/o.jpg', + environ={'REQUEST_METHOD': 'PUT'}, body='some data') self.app.update_request(req) - req.body_file = StringIO('some data') res = controller.PUT(req) expected = str(expected) self.assertEquals(res.status[:len(expected)], expected)