Connect to the host and port specified in __init__.
(self)
| 1022 | ) |
| 1023 | |
| 1024 | def connect(self): |
| 1025 | """Connect to the host and port specified in __init__.""" |
| 1026 | sys.audit("http.client.connect", self, self.host, self.port) |
| 1027 | self.sock = self._create_connection( |
| 1028 | (self.host,self.port), self.timeout, self.source_address) |
| 1029 | # Might fail in OSs that don't implement TCP_NODELAY |
| 1030 | try: |
| 1031 | self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) |
| 1032 | except OSError as e: |
| 1033 | if e.errno != errno.ENOPROTOOPT: |
| 1034 | raise |
| 1035 | |
| 1036 | if self._tunnel_host: |
| 1037 | self._tunnel() |
| 1038 | |
| 1039 | def close(self): |
| 1040 | """Close the connection to the HTTP server.""" |