'Set up host and port for HTTP CONNECT tunnelling.
In a connection that uses HTTP Connect tunneling, the host passed to the
constructor is used as proxy server that relays all communication to the
endpoint passed to set_tunnel. This is done by sending a HTTP CONNECT
request to the proxy server when the connection is established.
This method must be called before the HTML connection has been
established.
The headers argument should be a mapping of extra HTTP headers
to send with the CONNECT request.'

def set_tunnel(self, host, port=None, headers=None):

    if self.sock:
        raise RuntimeError("Can't    setup    tunnel    for    established    connection.")
    self._tunnel_host = host
    self._tunnel_port = port
    if headers:
        self._tunnel_headers = headers
    else:
        self._tunnel_headers.clear()
