Add missing content-length header

This patch adds missing content-length header
param into swift_upload_object() method.
Without it object upload handling could be failed
with "411 Length Required" error if Ceph is used
as an object storage.

Change-Id: Id0813806abb36a6f015efd13ec987492a3701476
Closes-Bug: #1352256
This commit is contained in:
Paul Karikh 2015-05-25 17:48:45 +03:00
parent e9b4ad259d
commit 8201d65cf9
2 changed files with 5 additions and 1 deletions

View File

@ -286,6 +286,7 @@ def swift_upload_object(request, container_name, object_name,
etag = swift_api(request).put_object(container_name, etag = swift_api(request).put_object(container_name,
object_name, object_name,
object_file, object_file,
content_length=size,
headers=headers) headers=headers)
obj_info = {'name': object_name, 'bytes': size, 'etag': etag} obj_info = {'name': object_name, 'bytes': size, 'etag': etag}

View File

@ -184,16 +184,18 @@ class SwiftApiTests(test.APITestCase):
headers = {'X-Object-Meta-Orig-Filename': fake_name} headers = {'X-Object-Meta-Orig-Filename': fake_name}
swift_api = self.stub_swiftclient() swift_api = self.stub_swiftclient()
test_file = FakeFile()
swift_api.put_object(container.name, swift_api.put_object(container.name,
obj.name, obj.name,
IsA(FakeFile), IsA(FakeFile),
content_length=test_file.size,
headers=headers) headers=headers)
self.mox.ReplayAll() self.mox.ReplayAll()
api.swift.swift_upload_object(self.request, api.swift.swift_upload_object(self.request,
container.name, container.name,
obj.name, obj.name,
FakeFile()) test_file)
def test_swift_upload_object_without_file(self): def test_swift_upload_object_without_file(self):
container = self.containers.first() container = self.containers.first()
@ -203,6 +205,7 @@ class SwiftApiTests(test.APITestCase):
swift_api.put_object(container.name, swift_api.put_object(container.name,
obj.name, obj.name,
None, None,
content_length=0,
headers={}) headers={})
self.mox.ReplayAll() self.mox.ReplayAll()