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
(cherry picked from commit 8201d65cf9)
This commit is contained in:
Paul Karikh 2015-05-25 17:48:45 +03:00 committed by Matt Fischer
parent 0f652fd6a7
commit 181e43fe00
2 changed files with 5 additions and 1 deletions

View File

@ -287,6 +287,7 @@ def swift_upload_object(request, container_name, object_name,
etag = swift_api(request).put_object(container_name,
object_name,
object_file,
content_length=size,
headers=headers)
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}
swift_api = self.stub_swiftclient()
test_file = FakeFile()
swift_api.put_object(container.name,
obj.name,
IsA(FakeFile),
content_length=test_file.size,
headers=headers)
self.mox.ReplayAll()
api.swift.swift_upload_object(self.request,
container.name,
obj.name,
FakeFile())
test_file)
def test_swift_upload_object_without_file(self):
container = self.containers.first()
@ -203,6 +205,7 @@ class SwiftApiTests(test.APITestCase):
swift_api.put_object(container.name,
obj.name,
None,
content_length=0,
headers={})
self.mox.ReplayAll()