Esempio n. 1
0
        public static RequestResult RequestUrl(string url)
        {
            RequestResult urlResult = new RequestResult(url);

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "HEAD";
                request.KeepAlive = false;

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    HttpHeaderInfo responseInfo = new HttpHeaderInfo();
                    responseInfo.StatusCode = response.StatusCode;
                    responseInfo.ContentType = response.ContentType;
                    responseInfo.LastModified = response.LastModified;
                    responseInfo.ContentLength = response.ContentLength;

                    urlResult.HttpHeaderInfo = responseInfo;
                    urlResult.Success = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occured reading: " + url);
                Console.WriteLine("Full exception:");
                Console.WriteLine(ex.ToString());
            }

            return urlResult;
        }
Esempio n. 2
0
 public RequestResult(string url)
 {
     HttpHeaderInfo = new HttpHeaderInfo();
     Error = null;
     ErrorMessage = "";
     Url = url;
     Success = false;
 }