public static HTTPRequest HttpCallback(HTTPResponse response) { SpiderRequest request = response.request.Addition as SpiderRequest; var sResponse = new SpiderResponse(request, response); sResponse = RunResponseMiddleware(currentSpider._ResponseMiddleware, sResponse); if (sResponse == null) { return(null); } else { var n = request.callback(sResponse); if (!isRunning) { return(null); } if (n == null) { return(null); } n = RunRequestMiddleware(currentSpider._RequestMiddleware, n); return(response.MakeRequest(n.method, n.Url, n, HttpCallback, n.Cookie, n.AdditionHeader, n.PostData)); } }
static SpiderResponse RunResponseMiddleware(List <ResponseMiddlewareBase> middlewareList, SpiderResponse response) { foreach (var item in middlewareList) { response = item.Process(response); if (response == null) { return(null); } } return(response); }
abstract public SpiderRequest Start(SpiderResponse response);