~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/download_ui.py

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        self._branch = branch
35
35
        self.log = branch.log
36
36
 
37
 
    def default(self, request, response):
 
37
    def __call__(self, environ, start_response):
38
38
        # /download/<rev_id>/<file_id>/[filename]
39
39
        z = time.time()
40
40
        h = self._branch.history
43
43
        try:
44
44
            args = []
45
45
            while 1:
46
 
                arg = path_info_pop(request.environ)
 
46
                arg = path_info_pop(environ)
47
47
                if arg is None:
48
48
                    break
49
49
                args.append(arg)
59
59
                mime_type = 'application/octet-stream'
60
60
 
61
61
            self.log.info('/download %s @ %s (%d bytes)', path, h.get_revno(revid), len(content))
62
 
            response.headers['Content-Type'] = mime_type
63
 
            response.headers['Content-Length'] = len(content)
64
 
            response.headers['Content-Disposition'] = 'attachment; filename=%s'%(filename,)
65
 
            response.write(content)
 
62
            headers = [
 
63
                ('Content-Type', mime_type),
 
64
                ('Content-Length', len(content)),
 
65
                ('Content-Disposition', 'attachment; filename=%s'%(filename,)),
 
66
                ]
 
67
            start_response('200 OK', headers)
 
68
            return [content]
66
69
        finally:
67
70
            h._branch.unlock()