'__negotiatehttp(self,destaddr,destport)
Negotiates a connection through an HTTP server.'

def __negotiatehttp(self, destaddr, destport):

    if (self.__proxy[3] == False):
        addr = socket.gethostbyname(destaddr)
    else:
        addr = destaddr
    self.sendall(((((((('CONNECT    ' + addr) + ':') + str(destport)) + '    HTTP/1.1\r\n') + 'Host:    ') + destaddr) + '\r\n\r\n'))
    resp = self.recv(1)
    while (resp.find('\r\n\r\n') == (-1)):
        resp = (resp + self.recv(1))
    statusline = resp.splitlines()[0].split('    ', 2)
    if (statusline[0] not in ('HTTP/1.0', 'HTTP/1.1')):
        self.close()
        raise GeneralProxyError((1, _generalerrors[1]))
    try:
        statuscode = int(statusline[1])
    except ValueError:
        self.close()
        raise GeneralProxyError((1, _generalerrors[1]))
    if (statuscode != 200):
        self.close()
        raise HTTPError((statuscode, statusline[2]))
    self.__proxysockname = ('0.0.0.0', 0)
    self.__proxypeername = (addr, destport)
