Commit a6381fd4 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

pithos: Fix partial content responses

Refs: #4063
parent f71c9fa4
......@@ -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__)
......@@ -187,7 +188,12 @@ 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)
# 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
......@@ -1037,11 +1037,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