Example #1
0
 public IndexerRequest(string url, HttpAccept httpAccept)
 {
     HttpRequest = new HttpRequest(url, httpAccept);
 }
Example #2
0
        public string POST(string url, string referer, string contentType, List <byte[]> data, List <string> headers, CookieContainer c, WebProxy proxy, HttpAccept accept, int timeOut = 100000)
        {
            try
            {
                req = (HttpWebRequest)WebRequest.Create(url);

                if (proxy != null)
                {
                    req.Proxy           = proxy;
                    req.PreAuthenticate = true;
                    req.Timeout         = timeOut;
                }

                //req.Timeout = 15000;
                req.ContentType       = contentType;//"multipart/form-data; boundary=" + boundary;
                req.Method            = "POST";
                req.KeepAlive         = true;
                req.Referer           = referer;
                req.AllowAutoRedirect = true;
                req.UserAgent         = USERAGENT;
                req.Accept            = accept.ToString();
                if (headers != null)
                {
                    foreach (string s in headers)
                    {
                        req.Headers.Add(s);
                    }
                }
                req.CookieContainer = c == null ? new CookieContainer() : c;
                req.ServicePoint.Expect100Continue    = false;
                ServicePointManager.Expect100Continue = false;
                req.AutomaticDecompression            = DecompressionMethods.GZip;

                Stream stream = req.GetRequestStream();
                foreach (byte[] b in data)
                {
                    stream.Write(b, 0, b.Length);
                }
                stream.Close();

                HttpWebResponse response = (HttpWebResponse)req.GetResponse();

                StreamReader reader = new StreamReader(response.GetResponseStream());
                string       RS     = reader.ReadToEnd();

                reader.Close();
                req.Abort();
                stream.Close();

                return(RS);
            }
            catch (Exception ex)
            {
                if (req == null)
                {
                    throw ex;
                }
                return("[[[ERROR]]]");
            }
        }
Example #3
0
 public ImportListRequest(string url, HttpAccept httpAccept)
 {
     HttpRequest = new HttpRequest(url, httpAccept);
 }
Example #4
0
        public string GET(string url, string referer, CookieContainer c, List <string> headers, WebProxy proxy, HttpAccept accept, int timeOut = 60000)
        {
            try
            {
                req = (HttpWebRequest)WebRequest.Create(url);

                if (proxy != null)
                {
                    req.Proxy           = proxy;
                    req.PreAuthenticate = true;
                    req.Timeout         = timeOut;
                }

                req.Timeout         = 10000;
                req.CookieContainer = c == null ? new CookieContainer() : c;
                req.Referer         = referer;
                req.Accept          = accept.ToString();
                req.UserAgent       = USERAGENT;
                if (headers != null)
                {
                    foreach (string s in headers)
                    {
                        req.Headers.Add(s);
                    }
                }
                req.AllowAutoRedirect                 = true;
                req.KeepAlive                         = true;
                req.AutomaticDecompression            = DecompressionMethods.GZip;
                ServicePointManager.Expect100Continue = false;
                req.ServicePoint.Expect100Continue    = false;

                HttpWebResponse response = (HttpWebResponse)req.GetResponse();

                Stream       stream = response.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                string       RS     = reader.ReadToEnd();
                response.Close();
                req.Abort();
                stream.Close();
                return(RS);
            }
            catch (Exception ex)
            {
                if (req == null)
                {
                    throw ex;
                }
                return("[[[ERROR]]]");
            }
        }