public void Add(TaskGroup_FileCheck_OneData d) { if (data != null) { data.Add(d); } }
private TaskGroup_FileCheck_OneData ScanRequestGetBody(string url, string userAgent) { Stopwatch st = new Stopwatch(); st.Start(); TaskGroup_FileCheck_OneData result = new TaskGroup_FileCheck_OneData(url); HttpHelper.HttpParam hp = new HttpHelper.HttpParam() { URL = url, UserAgent = userAgent, ContentType = "application/json;charset=unicode", Timeout = TimeSpan.FromSeconds(1), Method = HttpHelper.HttpVerb.Get, AllowAutoRedirect = false, Accept = "*/*", Referer = "http://www.baidu.com/", }; HttpHelper.HttpResult hr = HttpHelper.Request(hp); if (hr.Result != null) { result.contentType = hr.ContentType; result.length = hr.ContentLength; result.server = hr.Server; result.code = (int)hr.StatusCode; result.powerBy = hr.Header.Get("X-Powered-By"); } result.time = st.ElapsedMilliseconds; return(result); }
private TaskGroup_FileCheck_OneData ScanRequestGetHeader(string url) { Stopwatch st = new Stopwatch(); st.Start(); TaskGroup_FileCheck_OneData result = new TaskGroup_FileCheck_OneData(url); HttpHelper.HttpResult hr = HttpHelper.HeadInfo(url); if (hr.Result != null && hr.IsCompleted) { result.contentType = hr.ContentType; result.length = hr.ContentLength; result.server = hr.Server; result.code = (int)hr.StatusCode; result.powerBy = hr.Header.Get("X-Powered-By"); } result.time = st.ElapsedMilliseconds; return(result); }
public override object OneTask_Do(object data) { if (data == null || !(data is string)) { return(null); } string strDomain = CommonTool.formatDomain((string)data); string strUA = GlobalVar.Instance.uaList.GetUA(globalSetting.UAType); TaskGroup_FileCheck_Data list = new TaskGroup_FileCheck_Data(); foreach (String scanSuffix in suffixDirs) { string url = strDomain + scanSuffix; //GlobalVar.Instance.logger.Debug("checking: " + url); switch (this.setting.ScanType) { case ENUM_ScanType.eScanType_Head: TaskGroup_FileCheck_OneData oHeader = ScanRequestGetHeader(url); if (oHeader.code == 404 || oHeader.code == 0) { continue; //list.Add(oHeader); } else if (oHeader.code == 301 || oHeader.code == 302) { if (this.setting.IsShow301302) { list.Add(oHeader); } } else if (oHeader.code == 500) { if (this.setting.IsShow500) { list.Add(oHeader); } } else { list.Add(oHeader); } break; case ENUM_ScanType.eScanType_Get: TaskGroup_FileCheck_OneData oBody = ScanRequestGetBody(url, strUA); if (oBody.code == 404 || oBody.code == 0) { continue; //list.Add(oBody); } else if (oBody.code == 301 || oBody.code == 302) { if (this.setting.IsShow301302) { list.Add(oBody); } } else if (oBody.code == 500) { if (this.setting.IsShow500) { list.Add(oBody); } } else { list.Add(oBody); } break; } } Thread.Sleep(globalSetting.IntervalTimeMS); return(list); }