Esempio n. 1
0
        /// <summary>
        /// GET获取原始字节数组
        /// </summary>
        /// <param name="url"></param>
        /// <param name="referer"></param>
        /// <returns></returns>
        public byte[] GetRaw(string url, string referer = null)
        {
            var rawHandler = new RawHandler();
            var conn       = buildRequest(url);

            if (referer != null)
            {
                conn.SetHeader(HttpRequestHeader.Referer, referer);
            }
            conn.SetProcessor(rawHandler);
            return(SendRequest(conn) as byte[]);
        }
Esempio n. 2
0
        /// <summary>
        /// GET获取原始字节数组
        /// </summary>
        /// <param name="url"></param>
        /// <param name="referer"></param>
        /// <returns></returns>
        public async Task <byte[]> GetRawAsync(string url, string referer = null)
        {
            var rawHandler = new RawHandler();
            var conn       = buildRequest(url);

            if (referer != null)
            {
                conn.SetHeader(HttpRequestHeader.Referer, referer);
            }
            conn.SetProcessor(rawHandler);
            return(await SendRequestAsync(conn) as byte[]);
        }
Esempio n. 3
0
        public async override Task <object> Execute(BalancerData balancerData, HttpContext context, RawHandler handler)
        {
            var vhost = context.Items["bal-vhost"] as BalancerOption;
            var key   = balancerData.Scores.OrderByDescending(x => x.Value).FirstOrDefault().Key;
            var node  = vhost.Nodes[key];
            await handler.HandleRequest(context, node);

            return(node);
        }
Esempio n. 4
0
        public async override Task <object> Execute(BalancerData balancerData, HttpContext context, RawHandler handler)
        {
            var vhost = context.Items["bal-vhost"] as BalancerOption;

            balancerData.LastServed = (balancerData.LastServed + 1) % vhost.Nodes.Length;
            var node = vhost.Nodes[balancerData.LastServed];
            await handler.HandleRequest(context, node);

            return(node);
        }
Esempio n. 5
0
 public abstract Task <object> Execute(BalancerData balancerData, HttpContext context, RawHandler handler);