Show More
@@ -70,12 +70,10 b' class wsgirequest(object):' | |||||
70 | for s in util.filechunkiter(self.inp, limit=length): |
|
70 | for s in util.filechunkiter(self.inp, limit=length): | |
71 | pass |
|
71 | pass | |
72 |
|
72 | |||
73 |
def respond(self, status, type |
|
73 | def respond(self, status, type, filename=None, length=None): | |
74 | if self._start_response is not None: |
|
74 | if self._start_response is not None: | |
75 |
|
75 | |||
76 | self.httphdr(type, filename, length) |
|
76 | self.httphdr(type, filename, length) | |
77 | if not self.headers: |
|
|||
78 | raise RuntimeError("request.write called before headers sent") |
|
|||
79 |
|
77 | |||
80 | for k, v in self.headers: |
|
78 | for k, v in self.headers: | |
81 | if not isinstance(v, str): |
|
79 | if not isinstance(v, str): | |
@@ -125,10 +123,9 b' class wsgirequest(object):' | |||||
125 | def header(self, headers=[('Content-Type','text/html')]): |
|
123 | def header(self, headers=[('Content-Type','text/html')]): | |
126 | self.headers.extend(headers) |
|
124 | self.headers.extend(headers) | |
127 |
|
125 | |||
128 |
def httphdr(self, type |
|
126 | def httphdr(self, type, filename=None, length=None, headers={}): | |
129 | headers = headers.items() |
|
127 | headers = headers.items() | |
130 | if type is not None: |
|
128 | headers.append(('Content-Type', type)) | |
131 | headers.append(('Content-Type', type)) |
|
|||
132 | if filename: |
|
129 | if filename: | |
133 | filename = (filename.split('/')[-1] |
|
130 | filename = (filename.split('/')[-1] | |
134 | .replace('\\', '\\\\').replace('"', '\\"')) |
|
131 | .replace('\\', '\\\\').replace('"', '\\"')) |
@@ -800,13 +800,12 b' def archive(web, req, tmpl):' | |||||
800 | name = "%s-%s" % (reponame, arch_version) |
|
800 | name = "%s-%s" % (reponame, arch_version) | |
801 | mimetype, artype, extension, encoding = web.archive_specs[type_] |
|
801 | mimetype, artype, extension, encoding = web.archive_specs[type_] | |
802 | headers = [ |
|
802 | headers = [ | |
803 | ('Content-Type', mimetype), |
|
|||
804 | ('Content-Disposition', 'attachment; filename=%s%s' % (name, extension)) |
|
803 | ('Content-Disposition', 'attachment; filename=%s%s' % (name, extension)) | |
805 | ] |
|
804 | ] | |
806 | if encoding: |
|
805 | if encoding: | |
807 | headers.append(('Content-Encoding', encoding)) |
|
806 | headers.append(('Content-Encoding', encoding)) | |
808 | req.header(headers) |
|
807 | req.header(headers) | |
809 | req.respond(HTTP_OK) |
|
808 | req.respond(HTTP_OK, mimetype) | |
810 |
|
809 | |||
811 | ctx = webutil.changectx(web.repo, req) |
|
810 | ctx = webutil.changectx(web.repo, req) | |
812 | archival.archive(web.repo, req, cnode, artype, prefix=name, |
|
811 | archival.archive(web.repo, req, cnode, artype, prefix=name, |
General Comments 0
You need to be logged in to leave comments.
Login now