Return content-length header in download requests

Change-Id: Ifc7ff18bcedf8de4ee809ccc613956dc543a269e
This commit is contained in:
Mike Fedosin 2016-10-07 17:28:45 +03:00
parent e6d7af4cf8
commit 27c19ab82d
2 changed files with 7 additions and 1 deletions

View File

@ -484,8 +484,8 @@ class ResponseSerializer(api_versioning.VersionedResource,
response.headers['Content-MD5'] = meta['md5'] response.headers['Content-MD5'] = meta['md5']
response.headers['X-Openstack-Glare-Content-SHA1'] = meta['sha1'] response.headers['X-Openstack-Glare-Content-SHA1'] = meta['sha1']
response.headers['X-Openstack-Glare-Content-SHA256'] = meta['sha256'] response.headers['X-Openstack-Glare-Content-SHA256'] = meta['sha256']
response.headers['Content-Length'] = str(meta['size'])
response.app_iter = iter(data) response.app_iter = iter(data)
response.content_length = str(meta['size'])
@staticmethod @staticmethod
def _serialize_location(response, result): def _serialize_location(response, result):

View File

@ -17,6 +17,7 @@ import hashlib
import uuid import uuid
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import requests
from glare.tests.functional import base from glare.tests.functional import base
@ -777,6 +778,11 @@ class TestBlobs(base.TestArtifact):
self.assertEqual(sha1, art['blob']['sha1']) self.assertEqual(sha1, art['blob']['sha1'])
self.assertEqual(sha256, art['blob']['sha256']) self.assertEqual(sha256, art['blob']['sha256'])
# check that content-length is in response
response = requests.get(self._url(url + '/blob'),
headers=self._headers())
self.assertEqual('27', response.headers["content-length"])
blob_data = self.get(url=url + '/blob') blob_data = self.get(url=url + '/blob')
self.assertEqual(data, blob_data) self.assertEqual(data, blob_data)