public void TestGet() { HttpClient client = new HttpClient { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0" }; string page = client.Get("http://www.google.com"); Assert.IsTrue(page.Contains("<title>Google</title>")); }
public void TestHttpsProxy() { HttpClient client = new HttpClient(new Proxy(HttpsProxy)) { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0" }; string page = client.Get("https://httpbin.org/get"); Assert.IsTrue(page.Contains(client.UserAgent)); }
public void TestHttpProxy() { HttpClient client = new HttpClient(new Proxy(HttpsProxy)) { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", Encoding = Encoding.GetEncoding("iso-8859-2"), AcceptEncoding = "gzip" }; string page = client.Get("http://darkwarez.pl"); Assert.IsTrue(page.Contains("Polskie Forum Warez! Najnowsze linki")); }
public void TestGzipDecodingAndReferer() { HttpClient client = new HttpClient { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", Referer = "https://httpbin.org/" }; string page = client.Get("https://httpbin.org/gzip"); Assert.IsTrue(page.Contains(client.UserAgent)); // check for referer Assert.IsTrue(page.Contains("https://httpbin.org/")); }
public void TestSocksHttpsProxyGzipEndcoding() { HttpClient client = new HttpClient(new Proxy(Socksproxy)) { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", AcceptEncoding = "gzip" }; string page = client.Get("https://httpbin.org/get"); Assert.IsTrue(page.Contains(client.UserAgent)); }
public void TestSocksHttpProxy() { HttpClient client = new HttpClient(new Proxy(Socksproxy)) { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", Encoding = Encoding.GetEncoding("iso-8859-2"), AcceptEncoding = "deflate" }; string page = client.Get("http://darkwarez.pl/forum/"); Assert.IsTrue(page.Contains("darkwarez.pl - Gry, Muzyka, Filmy, Download")); }
public void TestSocksHttpsProxyDeflateEncoding() { string proxyAddress = "202.43.147.226:1080"; HttpClient client = new HttpClient(new Proxy(proxyAddress)) { UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0", AcceptEncoding = "deflate" }; string page = client.Get("https://httpbin.org/get"); Assert.IsTrue(page.Contains(client.UserAgent)); }