HTTP隧道 (专业版)
C# 接入指南

隧道验证方式

地址:http-pro.abuyun.com,端口:9010

隧道验证方式

HTTP隧道拥有两种授权模式:

  • 请求头(默认)

通过用户名/密码的形式进行身份认证,该认证信息最终会转换为『Proxy-Authorization』协议头跟随请求一起发出。

为便于部分语言进行接入,平台亦支持通过『Authorization』协议头进行隧道身份验证。

  • 绑定IP(暂未启用)

只须绑定用户发起请求的服务器IP即可。

一条代理隧道只能绑定一个IP,同一IP可以分别绑定到专业版、动态版、经典版代理隧道各一条。

              
    # -*-*-
    # 感谢骚男 『yvon (QQ: 917512804)』 提供的源代码
    # -*-*-

    // 要访问的目标页面
    string targetUrl = "http://test.abuyun.com";
    //string targetUrl = "http://proxy.abuyun.com/switch-ip";
    //string targetUrl = "http://proxy.abuyun.com/current-ip";

    // 代理服务器
    string proxyHost = "http://http-pro.abuyun.com";
    string proxyPort = "9010";

    // 代理隧道验证信息
    string proxyUser = "H01234567890123P";
    string proxyPass = "0123456789012345";

    // 设置代理服务器
    var proxy         = new WebProxy();
    proxy.Address     = new Uri(string.Format("{0}:{1}", proxyHost, proxyPort));
    proxy.Credentials = new NetworkCredential(proxyUser, proxyPass);

    ServicePointManager.Expect100Continue = false;

    var request = WebRequest.Create(targetUrl) as HttpWebRequest;

    request.AllowAutoRedirect = true;
    request.KeepAlive = true;
    request.Method    = "GET";
    request.Proxy     = proxy;

    //request.Timeout = 20000;
    //request.ServicePoint.ConnectionLimit = 512;
    //request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36";
    //request.Headers.Add("Cache-Control", "max-age=0");
    //request.Headers.Add("DNT", "1");

    using (var response = request.GetResponse() as HttpWebResponse)
    using (var sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
    {
        string htmlStr = sr.ReadToEnd();
    }                
              
体验服务
现在开始,体验阿布云大数据服务
计算、网络、大数据、人工智能,阿布云助您飞跃发展