Show More
@@ -72,15 +72,21 b' class wsgirequest(object):' | |||
|
72 | 72 | |
|
73 | 73 | def respond(self, status, type, filename=None, length=None): |
|
74 | 74 | if self._start_response is not None: |
|
75 | ||
|
76 |
|
|
|
75 | self.headers.append(('Content-Type', type)) | |
|
76 | if filename: | |
|
77 | filename = (filename.split('/')[-1] | |
|
78 | .replace('\\', '\\\\').replace('"', '\\"')) | |
|
79 | self.headers.append(('Content-Disposition', | |
|
80 | 'inline; filename="%s"' % filename)) | |
|
81 | if length is not None: | |
|
82 | self.headers.append(('Content-Length', str(length))) | |
|
77 | 83 | |
|
78 | 84 | for k, v in self.headers: |
|
79 | 85 | if not isinstance(v, str): |
|
80 | raise TypeError('header value must be string: %r' % v) | |
|
86 | raise TypeError('header value must be string: %r' % (v,)) | |
|
81 | 87 | |
|
82 | 88 | if isinstance(status, ErrorResponse): |
|
83 | self.header(status.headers) | |
|
89 | self.headers.extend(status.headers) | |
|
84 | 90 | if status.code == HTTP_NOT_MODIFIED: |
|
85 | 91 | # RFC 2616 Section 10.3.5: 304 Not Modified has cases where |
|
86 | 92 | # it MUST NOT include any headers other than these and no |
@@ -120,21 +126,6 b' class wsgirequest(object):' | |||
|
120 | 126 | def close(self): |
|
121 | 127 | return None |
|
122 | 128 | |
|
123 | def header(self, headers=[('Content-Type','text/html')]): | |
|
124 | self.headers.extend(headers) | |
|
125 | ||
|
126 | def httphdr(self, type, filename=None, length=None, headers={}): | |
|
127 | headers = headers.items() | |
|
128 | headers.append(('Content-Type', type)) | |
|
129 | if filename: | |
|
130 | filename = (filename.split('/')[-1] | |
|
131 | .replace('\\', '\\\\').replace('"', '\\"')) | |
|
132 | headers.append(('Content-Disposition', | |
|
133 | 'inline; filename="%s"' % filename)) | |
|
134 | if length is not None: | |
|
135 | headers.append(('Content-Length', str(length))) | |
|
136 | self.header(headers) | |
|
137 | ||
|
138 | 129 | def wsgiapplication(app_maker): |
|
139 | 130 | '''For compatibility with old CGI scripts. A plain hgweb() or hgwebdir() |
|
140 | 131 | can and should now be used as a WSGI application.''' |
General Comments 0
You need to be logged in to leave comments.
Login now