Example #1
0
GString		GHttp::Get(const GString &g)
{
	GString	page(g);
	if (!page.StartWith("http://"))
	{
		page = this->_host + page;
		if (!page.StartWith("http://"))
			page = "http://" + page;
	}
	GString	str = "GET " + page + " HTTP/1.1\r\n";
	str += "Host: " + this->_host + "\r\n";
	if (!this->_proxyUser.IsEmpty())
	{
		str += "Proxy-Authorization: Basic " + GCryptography::GBase64::Encode(this->_proxyUser + ":" + this->_proxyPass) + "\r\n";
		str += "Proxy-Connection : keep-alive\r\n";
	}
	else
	{
		str += "Keep-Alive: 20000\r\n";
		str += "Connection : keep-alive\r\n";
	}
	if (!this->_user.IsEmpty())
		str += "Authorization: Basic " + GCryptography::GBase64::Encode(this->_user + ":" + this->_pass) + "\r\n";
	str += "\r\n";
	this->_socket.Send(str);
	GString rectot;
	while (true)
	{
		GString rec;
		rec = this->_socket.Receive();
		if (rec.Size() < 1024)
		{
			rectot += rec;
			GString	sub = rec.Substr(0, rec.Find("\r\n"));
			GStringList	tab = sub.Split(" ");
			if (tab.Size() > 2)
			{
				//GESTION DES ERREUR
			}
			int	pos = rec.Find("\r\n\r\n");
			if (pos != GString::NotFound)
				;//this->_response = this->_response.Substr(pos + 4);
		}
	}
	return (rectot);
}