Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2012-03-26 18:23:28 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2012-03-26 18:23:28 (GMT)
commita4e1395c8af463853c68938246fa1c2b6ea8901b (patch)
tree7c391cabfacc457b52a0163d535edb61346f701e
parent9298786ca91ce6d305bc8ea1d2d87a47d2189d94 (diff)
Set response header before starting data sending to avoid overriding content type
-rw-r--r--restful_document/document.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/restful_document/document.py b/restful_document/document.py
index 791c39d..786aa7d 100644
--- a/restful_document/document.py
+++ b/restful_document/document.py
@@ -103,6 +103,10 @@ class Document(ad.Document):
reply.append(name)
return self.all_properties(reply)
elif isinstance(self.metadata[prop], ad.BlobProperty):
+ stat = self.stat_blob(prop)
+ if stat and stat['size']:
+ env.responce['Content-Length'] = stat['size']
+ env.responce['Content-Type'] = self.metadata[prop].mime_type
return self.send_blob(prop)
else:
return self[prop]
@@ -118,11 +122,6 @@ class Document(ad.Document):
self.set_blob(prop, stream)
def send_blob(self, prop):
- stat = self.stat_blob(prop)
- if stat and stat['size']:
- env.responce['Content-Length'] = stat['size']
- env.responce['Content-Type'] = self.metadata[prop].mime_type
-
stream = self.get_blob(prop)
while True:
chunk = stream.read(_PAGE_SIZE)