Exemplo n.º 1
0
        private HttpWebRequest CreateWebReqeust(string url)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method          = "GET";
            request.ProtocolVersion = HttpVersion.Version11;
            request.UserAgent       =
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
            request.AllowAutoRedirect      = true;
            request.KeepAlive              = true;
            request.Pipelined              = true;
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

            // Timeouts don't work with GetResponseAsync() as it internally uses BeginGetResponse.
            // See docs: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.timeout(v=vs.110).aspx
            // Quote: The Timeout property has no effect on asynchronous requests made with the BeginGetResponse or BeginGetRequestStream method.
            // TODO: Use HttpClient instead?
            request.ReadWriteTimeout = settings.TimeOut * 1000;
            request.Timeout          = settings.TimeOut * 1000;
            //TODO: Fix site specific cookies!
            request.CookieContainer = SharedCookieService.GetUriCookieContainer(new Uri("https://www.tumblr.com/"));
            ServicePointManager.DefaultConnectionLimit = 400;
            request = SetWebRequestProxy(request, settings);
            return(request);
        }
Exemplo n.º 2
0
        protected HttpWebRequest CreateWebReqeust(string url)
        {
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method          = "GET";
            request.ProtocolVersion = HttpVersion.Version11;
            request.UserAgent       =
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
            request.AllowAutoRedirect      = true;
            request.KeepAlive              = true;
            request.Pipelined              = true;
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            request.ReadWriteTimeout       = shellService.Settings.TimeOut * 1000;
            request.Timeout         = -1;
            request.CookieContainer = SharedCookieService.GetUriCookieContainer(new Uri("https://www.tumblr.com/"));
            ServicePointManager.DefaultConnectionLimit = 400;
            request = SetWebRequestProxy(request, shellService.Settings);
            return(request);
        }
        protected HttpWebRequest CreateWebReqeust(string limit, string offset)
        {
            string url = @"https://www.tumblr.com/svc/indash_blog?tumblelog_name_or_id=" + blog.Name +
                         @"&post_id=&limit=" + limit + "&offset=" + offset + "&should_bypass_safemode=true";
            var request = (HttpWebRequest)WebRequest.Create(url);

            request.Method          = "GET";
            request.ContentType     = "application/json";
            request.ProtocolVersion = HttpVersion.Version11;
            request.UserAgent       =
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
            request.AllowAutoRedirect      = true;
            request.KeepAlive              = true;
            request.Pipelined              = true;
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            request.ReadWriteTimeout       = shellService.Settings.TimeOut * 1000;
            request.Timeout         = -1;
            request.CookieContainer = SharedCookieService.GetUriCookieContainer(new Uri("https://www.tumblr.com/"));
            ServicePointManager.DefaultConnectionLimit = 400;
            request         = SetWebRequestProxy(request, shellService.Settings);
            request.Referer = @"https://www.tumblr.com/dashboard/blog/" + blog.Name;
            request.Headers["X-Requested-With"] = "XMLHttpRequest";
            return(request);
        }
Exemplo n.º 4
0
        protected HttpWebRequest CreateWebReqeust(int pageNumber)
        {
            string url     = "https://www.tumblr.com/search/" + blog.Name + "/post_page/" + pageNumber.ToString();
            var    request = (HttpWebRequest)WebRequest.Create(url);

            request.Method          = "POST";
            request.Accept          = "application/json, text/javascript, */*; q=0.01";
            request.ContentType     = "application/x-www-form-urlencoded";
            request.ProtocolVersion = HttpVersion.Version11;
            request.UserAgent       =
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
            request.AllowAutoRedirect      = true;
            request.KeepAlive              = true;
            request.Pipelined              = true;
            request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            request.ReadWriteTimeout       = shellService.Settings.TimeOut * 1000;
            request.Timeout         = -1;
            request.CookieContainer = SharedCookieService.GetUriCookieContainer(new Uri("https://www.tumblr.com/"));
            ServicePointManager.DefaultConnectionLimit = 400;
            request         = SetWebRequestProxy(request, shellService.Settings);
            request.Referer = @"https://www.tumblr.com/search/" + blog.Name;
            request.Headers["X-Requested-With"] = "XMLHttpRequest";
            return(request);
        }