MCPcopy Index your code
hub / github.com/RustPython/RustPython / _check_close

Method _check_close

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

Source from the content-addressed store, hash-verified

399 self.will_close = True
400
401 def _check_close(self):
402 conn = self.headers.get("connection")
403 if self.version == 11:
404 # An HTTP/1.1 proxy is assumed to stay open unless
405 # explicitly closed.
406 if conn and "close" in conn.lower():
407 return True
408 return False
409
410 # Some HTTP/1.0 implementations have support for persistent
411 # connections, using rules different than HTTP/1.1.
412
413 # For older HTTP, Keep-Alive indicates persistent connection.
414 if self.headers.get("keep-alive"):
415 return False
416
417 # At least Akamai returns a "Connection: Keep-Alive" header,
418 # which was supposed to be sent by the client.
419 if conn and "keep-alive" in conn.lower():
420 return False
421
422 # Proxy-Connection is a netscape hack.
423 pconn = self.headers.get("proxy-connection")
424 if pconn and "keep-alive" in pconn.lower():
425 return False
426
427 # otherwise, assume it will close
428 return True
429
430 def _close_conn(self):
431 fp = self.fp

Callers 1

beginMethod · 0.95

Calls 2

getMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected