예제 #1
0
        Response postRequest(string url_from, string parameters, string Referer = null, CookieContainer cookies = null)
        {
            try
            {
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                using (var client = new BetterWebClient(cookies == null ? CookieContainer : cookies))
                {
                    client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0";
                    if (!string.IsNullOrWhiteSpace(Referer))
                    {
                        client.Headers[HttpRequestHeader.Referer] = Referer;
                    }
                    client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";

                    string response = client.UploadString(url_from, parameters);
                    extractCookies(client.ResponseHeaders["Set-Cookie"]);
                    return(new Response {
                        Page = response, Location = client.Location, StatusCode = client.StatusCode, ResponseUri = client.ResponseUri
                    });
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #2
0
        ///<summary>
        ///Removes Directory or file in HDFS
        ///<param name="path">Directory/File path to delete</param>
        ///<returns>HttpStatusCode</returns>
        ///</summary>
        public HttpStatusCode RmDir(string path)
        {
            // Create the final url with params
            string          url_path = "http://" + this.namenodeHost + ":" + this.namenodePort + WEBHDFS_CONTEXT_ROOT + "/" + path + "?op=DELETE&user.name=" + this.hdfsUsername;
            BetterWebClient wc       = new BetterWebClient();

            wc.UploadString(url_path, "DELETE", "");
            return(wc.StatusCode());
        }