/// <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[]); }
/// <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[]); }
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); }
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); }
public abstract Task <object> Execute(BalancerData balancerData, HttpContext context, RawHandler handler);