Get() 공개 메소드

Execute GET request.
public Get ( string url ) : string
url string
리턴 string
예제 #1
0
        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>"));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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"));
        }
예제 #4
0
        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/"));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }