Commit 761afc78 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Fix partial content responses

Refs: #4063
parent 9a9068b0
......@@ -48,6 +48,7 @@ from astakosclient.errors import AstakosClientException
from django.conf import settings
from snf_django.lib.api import faults
import itertools
log = getLogger(__name__)
......@@ -188,7 +189,15 @@ def update_response_headers(request, response):
response["Date"] = format_date_time(time())
if not response.has_header("Content-Length"):
response["Content-Length"] = len(response.content)
if response._is_string:
response["Content-Length"] = len(response.content)
if not (response.has_header('Content-Type') and
# save response content from been consumed if it is an iterator
response._container, data = itertools.tee(response._container)
response["Content-Length"] = len(str(data))
# Fix Vary and Cache-Control Headers. Issue: #3448
......@@ -1038,11 +1038,6 @@ def update_request_headers(request):
def update_response_headers(request, response):
if (not response.has_header('Content-Length') and
not (response.has_header('Content-Type') and
response['Content-Length'] = len(response.content)
# URL-encode unicode in headers.
meta = response.items()
for k, v in meta:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment