Connect to the host and port specified in __init__.
(self)
| 957 | response.close() |
| 958 | |
| 959 | def connect(self): |
| 960 | """Connect to the host and port specified in __init__.""" |
| 961 | sys.audit("http.client.connect", self, self.host, self.port) |
| 962 | self.sock = self._create_connection( |
| 963 | (self.host,self.port), self.timeout, self.source_address) |
| 964 | # Might fail in OSs that don't implement TCP_NODELAY |
| 965 | try: |
| 966 | self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) |
| 967 | except OSError as e: |
| 968 | if e.errno != errno.ENOPROTOOPT: |
| 969 | raise |
| 970 | |
| 971 | if self._tunnel_host: |
| 972 | self._tunnel() |
| 973 | |
| 974 | def close(self): |
| 975 | """Close the connection to the HTTP server.""" |
no test coverage detected