コード例 #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[]);
        }
コード例 #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[]);
        }
コード例 #3
0
ファイル: RequestCount.cs プロジェクト: zeppaman/RawCMS
        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);
        }
コード例 #4
0
ファイル: RoundRobin.cs プロジェクト: zeppaman/RawCMS
        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);
        }
コード例 #5
0
 public abstract Task <object> Execute(BalancerData balancerData, HttpContext context, RawHandler handler);