MCPcopy Index your code
hub / github.com/python/cpython / _read_status

Method _read_status

Lib/http/client.py:297–328  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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:

Callers 2

beginMethod · 0.95
_tunnelMethod · 0.80

Calls 8

_close_connMethod · 0.95
strFunction · 0.85
LineTooLongClass · 0.85
RemoteDisconnectedClass · 0.85
BadStatusLineClass · 0.85
readlineMethod · 0.45
splitMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected