WSGI conform list of (header, value) tuples.
(self)
| 2165 | |
| 2166 | @property |
| 2167 | def headerlist(self): |
| 2168 | """ WSGI conform list of (header, value) tuples. """ |
| 2169 | out = [] |
| 2170 | headers = list(self._headers.items()) |
| 2171 | if 'Content-Type' not in self._headers: |
| 2172 | headers.append(('Content-Type', [self.default_content_type])) |
| 2173 | if self._status_code in self.bad_headers: |
| 2174 | bad_headers = self.bad_headers[self._status_code] |
| 2175 | headers = [h for h in headers if h[0] not in bad_headers] |
| 2176 | out += [(name, val) for (name, vals) in headers for val in vals] |
| 2177 | if self._cookies: |
| 2178 | for c in self._cookies.values(): |
| 2179 | out.append(('Set-Cookie', _hval(c.OutputString()))) |
| 2180 | if py3k: |
| 2181 | out = [(k, v.encode('utf8').decode('latin1')) for (k, v) in out] |
| 2182 | return out |
| 2183 | |
| 2184 | content_type = HeaderProperty('Content-Type') |
| 2185 | content_length = HeaderProperty('Content-Length', reader=int, default=-1) |