original_docstring: __negotiatehttp(self,destaddr,destport)
  		Negotiates a connection through an HTTP server.
  		
docstring: negotiatehttp(self,destaddr,destport)
  Negotiates a connection through an HTTP server.
docstring_tokens: negotiatehttp ( self destaddr destport ) Negotiates a connection through an HTTP server .
code: def __negotiatehttp(self,destaddr,destport):
  		"""__negotiatehttp(self,destaddr,destport)
  		Negotiates a connection through an HTTP server.
  		"""
  		# If we need to resolve locally, we do this now
  		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")
  		# We read the response until we get the string "\r\n\r\n"
  		resp = self.recv(1)
  		while resp.find("\r\n\r\n")==-1:
  			resp = resp + self.recv(1)
  		# We just need the first line to check if the connection
  		# was successful
  		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)
code_tokens: 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 )
short_docstring: __negotiatehttp(self,destaddr,destport)
  Negotiates a connection through an HTTP server.
short_docstring_tokens: __negotiatehttp ( self destaddr destport ) Negotiates a connection through an HTTP server .
comment: """__negotiatehttp(self,destaddr,destport)
  		Negotiates a connection through an HTTP server.
  		"""$SEP$# If we need to resolve locally, we do this now
  $SEP$# We read the response until we get the string "\r\n\r\n"
  $SEP$# We just need the first line to check if the connection
  $SEP$# was successful
  