(self)
| 295 | self.will_close = _UNKNOWN # conn will close at end of response |
| 296 | |
| 297 | def _read_status(self): |
| 298 | line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") |
| 299 | if len(line) > _MAXLINE: |
| 300 | raise LineTooLong("status line") |
| 301 | if self.debuglevel > 0: |
| 302 | print("reply:", repr(line)) |
| 303 | if not line: |
| 304 | # Presumably, the server closed the connection before |
| 305 | # sending a valid response. |
| 306 | raise RemoteDisconnected("Remote end closed connection without" |
| 307 | " response") |
| 308 | try: |
| 309 | version, status, reason = line.split(None, 2) |
| 310 | except ValueError: |
| 311 | try: |
| 312 | version, status = line.split(None, 1) |
| 313 | reason = "" |
| 314 | except ValueError: |
| 315 | # empty version will cause next test to fail. |
| 316 | version = "" |
| 317 | if not version.startswith("HTTP/"): |
| 318 | self._close_conn() |
| 319 | raise BadStatusLine(line) |
| 320 | |
| 321 | # The status code is a three-digit number |
| 322 | try: |
| 323 | status = int(status) |
| 324 | if status < 100 or status > 999: |
| 325 | raise BadStatusLine(line) |
| 326 | except ValueError: |
| 327 | raise BadStatusLine(line) |
| 328 | return version, status, reason |
| 329 | |
| 330 | def begin(self, *, _max_headers=None): |
| 331 | if self.headers is not None: |
no test coverage detected