Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
761afc78
Commit
761afc78
authored
Sep 12, 2013
by
Sofia Papagiannaki
Browse files
pithos: Fix partial content responses
Refs: #4063
parent
9a9068b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-django-lib/snf_django/lib/api/__init__.py
View file @
761afc78
...
...
@@ -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
)
else
:
if
not
(
response
.
has_header
(
'Content-Type'
)
and
response
[
'Content-Type'
].
startswith
(
'multipart/byteranges'
)):
# save response content from been consumed if it is an iterator
response
.
_container
,
data
=
itertools
.
tee
(
response
.
_container
)
response
[
"Content-Length"
]
=
len
(
str
(
data
))
cache
.
add_never_cache_headers
(
response
)
# Fix Vary and Cache-Control Headers. Issue: #3448
...
...
snf-pithos-app/pithos/api/util.py
View file @
761afc78
...
...
@@ -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-Type'
].
startswith
(
'multipart/byteranges'
))):
response
[
'Content-Length'
]
=
len
(
response
.
content
)
# URL-encode unicode in headers.
meta
=
response
.
items
()
for
k
,
v
in
meta
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment