start_response()' callable as specified by PEP 3333
(self, status, headers,exc_info=None)
| 224 | self.set_content_length() |
| 225 | |
| 226 | def start_response(self, status, headers,exc_info=None): |
| 227 | """'start_response()' callable as specified by PEP 3333""" |
| 228 | |
| 229 | if exc_info: |
| 230 | try: |
| 231 | if self.headers_sent: |
| 232 | raise |
| 233 | finally: |
| 234 | exc_info = None # avoid dangling circular ref |
| 235 | elif self.headers is not None: |
| 236 | raise AssertionError("Headers already set!") |
| 237 | |
| 238 | self.status = status |
| 239 | self.headers = self.headers_class(headers) |
| 240 | status = self._convert_string_type(status, "Status") |
| 241 | self._validate_status(status) |
| 242 | |
| 243 | if __debug__: |
| 244 | for name, val in headers: |
| 245 | name = self._convert_string_type(name, "Header name") |
| 246 | val = self._convert_string_type(val, "Header value") |
| 247 | assert not is_hop_by_hop(name),\ |
| 248 | f"Hop-by-hop header, '{name}: {val}', not allowed" |
| 249 | |
| 250 | return self.write |
| 251 | |
| 252 | def _validate_status(self, status): |
| 253 | if _name_disallowed_re.search(status): |