byte[] GetConnectCmd(string hostName, int hostPort, bool useCredentials)
{
string cmd = string.Format("CONNECT {0}:{1} HTTP/1.1\r\n", hostName, hostPort);
cmd += string.Format("Host: {0}:{1}\r\n", hostName, hostPort);
if(useCredentials)
{
string credentials = GetBasicCredentials();
cmd += "Authorization: basic " + credentials + "\r\n";
cmd += "Proxy-Authorization: basic " + credentials + "\r\n";
}
cmd += "\r\n";
return Encoding.ASCII.GetBytes(cmd);
}