From 59ed8253f7822e36ddeffffb3342e132ef3c5130 Mon Sep 17 00:00:00 2001 From: Bryant Nelson Date: Thu, 28 Dec 2017 09:03:58 -0600 Subject: [PATCH] Improve randorg interface. --- RandOrgInterface.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RandOrgInterface.cs b/RandOrgInterface.cs index 47e5bc4..6072be1 100644 --- a/RandOrgInterface.cs +++ b/RandOrgInterface.cs @@ -26,7 +26,10 @@ public static int RandInt(int min, int max) string result = string.Empty; - WebRequest req = WebRequest.Create(url); + HttpWebRequest req = WebRequest.CreateHttp(url); + req.Timeout = 3000; + req.Accept = "text/html"; + req.UserAgent = @"Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"; WebResponse res = req.GetResponse(); StreamReader reader = new StreamReader(res.GetResponseStream()); result = reader.ReadToEnd();