MakeRequest() 개인적인 메소드

Выполнить запрос.
Response is null.
private MakeRequest ( HttpResponseMessage response, Uri uri, IWebProxy webProxy ) : WebCallResult
response System.Net.Http.HttpResponseMessage Ответ сервера
uri System.Uri Uri из которого получаем куки
webProxy IWebProxy Хост.
리턴 WebCallResult
예제 #1
0
파일: WebCall.cs 프로젝트: vknet/vk
 /// <summary>
 /// Выполнить запрос.
 /// </summary>
 /// <param name="url">URL.</param>
 /// <param name="webProxy">Данные прокси сервера.</param>
 /// <returns>Результат</returns>
 public static WebCallResult MakeCall(string url, IWebProxy webProxy = null)
 {
     using (var call = new WebCall(url, new Cookies(), webProxy))
     {
         var response = call._request.GetAsync(url).Result;
         return call.MakeRequest(response, new Uri(url), webProxy);
     }
 }
예제 #2
0
파일: WebCall.cs 프로젝트: odugen/vk
        private WebCallResult RedirectTo(string url)
        {
            var call = new WebCall(url, Result.Cookies);

            var request = call.Request;
            request.Method = "GET";
            request.ContentType = "text/html";
            request.Referer = Request.Referer;

            return call.MakeRequest();
        }
예제 #3
0
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        private WebCallResult RedirectTo(string url, string host = null, int?port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, Result.Cookies, host, port, proxyLogin, proxyPassword);

            var request = call.Request;

            request.Method      = "GET";
            request.ContentType = "text/html";
            request.Referer     = Request.Referer;

            return(call.MakeRequest(host, port, proxyLogin, proxyPassword));
        }
예제 #4
0
파일: WebCall.cs 프로젝트: ddfx/vk
        private WebCallResult RedirectTo(string url)
        {
            var call = new WebCall(url, Result.Cookies);

            var request = call.Request;

            request.Method      = "GET";
            request.ContentType = "text/html";
            request.Referer     = Request.Referer;

            return(call.MakeRequest());
        }
예제 #5
0
파일: WebCall.cs 프로젝트: slay9090/vk
        /// <summary>
        /// Post запрос из формы.
        /// </summary>
        /// <param name="form"> Форма. </param>
        /// <param name="webProxy"> Хост. </param>
        /// <returns> Результат </returns>
        public static WebCallResult Post(WebForm form, IWebProxy webProxy)
        {
            using (var call = new WebCall(url: form.ActionUrl, cookies: form.Cookies, webProxy: webProxy, allowAutoRedirect: false))
            {
                SpecifyHeadersForFormRequest(form: form, call: call);

                var request = call._request.PostAsync(requestUri: form.ActionUrl
                                                      , content: new FormUrlEncodedContent(nameValueCollection: form.GetFormFields()))
                              .Result;

                return(call.MakeRequest(response: request, uri: new Uri(uriString: form.ActionUrl), webProxy: webProxy));
            }
        }
예제 #6
0
파일: WebCall.cs 프로젝트: slay9090/vk
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url"> URL. </param>
        /// <param name="webProxy"> Хост. </param>
        /// <returns> Результат </returns>
        private WebCallResult RedirectTo(string url, IWebProxy webProxy = null)
        {
            using (var call = new WebCall(url: url, cookies: _result.Cookies, webProxy: webProxy))
            {
                var headers = call._request.DefaultRequestHeaders;
                headers.Add(name: "Method", value: "GET");
                headers.Add(name: "ContentType", value: "text/html");

                var response = call._request.GetAsync(requestUri: url).Result;

                return(call.MakeRequest(response: response, uri: new Uri(uriString: url), webProxy: webProxy));
            }
        }
예제 #7
0
파일: WebCall.cs 프로젝트: odugen/vk
        public static WebCallResult PostCall(string url, string parameters)
        {
            var call = new WebCall(url, new Cookies());
            call.Request.Method = "POST";
            call.Request.ContentType = "application/x-www-form-urlencoded";
            var data = Encoding.UTF8.GetBytes(parameters);
            call.Request.ContentLength = data.Length;

            using (var requestStream = call.Request.GetRequestStream())
                requestStream.Write(data, 0, data.Length);                

            return call.MakeRequest();
        }
예제 #8
0
파일: WebCall.cs 프로젝트: GooG2e/vk
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        private WebCallResult RedirectTo(string url, IWebProxy webProxy = null)
        {
            using (var call = new WebCall(url, _result.Cookies, webProxy))
            {
                var headers = call._request.DefaultRequestHeaders;
                headers.Add("Method", "GET");
                headers.Add("ContentType", "text/html");

                var response = call._request.GetAsync(url).Result;

                return(call.MakeRequest(response, new Uri(url), webProxy));
            }
        }
예제 #9
0
파일: WebCall.cs 프로젝트: odugen/vk
        public static WebCallResult Post(WebForm form)
        {
            var call = new WebCall(form.ActionUrl, form.Cookies);

            var request = call.Request;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            var formRequest = form.GetRequest();
            request.ContentLength = formRequest.Length;
            request.GetRequestStream().Write(formRequest, 0, formRequest.Length);
            request.AllowAutoRedirect = false;
            request.Referer = form.OriginalUrl;

            return call.MakeRequest();
        }
예제 #10
0
        public static WebCallResult PostCall(string url, string parameters)
        {
            var call = new WebCall(url, new Cookies());

            call.Request.Method      = "POST";
            call.Request.ContentType = "application/x-www-form-urlencoded";
            var data = Encoding.UTF8.GetBytes(parameters);

            call.Request.ContentLength = data.Length;

            using (var requestStream = call.Request.GetRequestStream())
                requestStream.Write(data, 0, data.Length);

            return(call.MakeRequest());
        }
예제 #11
0
파일: WebCall.cs 프로젝트: nijikilling/vk
        /// <summary>
        /// Post запрос из формы.
        /// </summary>
        /// <param name="form">Форма.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <returns>Результат</returns>
        public static WebCallResult Post(WebForm form, string host = null, int?port = null)
        {
            var call = new WebCall(form.ActionUrl, form.Cookies, host, port);

            var request = call.Request;

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            var formRequest = form.GetRequest();

            request.ContentLength = formRequest.Length;
            request.Referer       = form.OriginalUrl;
            request.GetRequestStream().Write(formRequest, 0, formRequest.Length);
            request.AllowAutoRedirect = false;

            return(call.MakeRequest(host, port));
        }
예제 #12
0
파일: WebCall.cs 프로젝트: faruk63/vk
        /// <summary>
        /// Выполнить POST запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="parameters">Параметры запроса.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        public static WebCallResult PostCall(string url, string parameters, string host = null, int?port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, new Cookies(), host, port, proxyLogin, proxyPassword)
            {
                Request =
                {
                    Method      = "POST",
                    ContentType = "application/x-www-form-urlencoded"
                }
            };

            var data = Encoding.UTF8.GetBytes(parameters);

            call.Request.ContentLength = data.Length;

            using (var requestStream = call.Request.GetRequestStream())
                requestStream.Write(data, 0, data.Length);

            return(call.MakeRequest(host, port, proxyLogin, proxyPassword));
        }
예제 #13
0
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url"> URL. </param>
        /// <param name="webProxy"> Данные прокси сервера. </param>
        /// <returns> Результат </returns>
        public static WebCallResult MakeCall(string url, IWebProxy webProxy = null)
        {
                #if DEBUG_HTTP
            LogWebCallRequestInfo("GET", url, null, webProxy);
            var watch = System.Diagnostics.Stopwatch.StartNew();
                        #endif

            using (var call = new WebCall(url: url, cookies: new Cookies(), webProxy: webProxy))
            {
                var response = call._request.GetAsync(requestUri: url).Result;
                var res      = call.MakeRequest(response: response, uri: new Uri(uriString: url), webProxy: webProxy);

                        #if DEBUG_HTTP
                watch.Stop();
                LogWebCallResultDebugInfo("GET", url, response, res, watch.ElapsedMilliseconds);
                                #endif

                return(res);
            }
        }
예제 #14
0
        /// <summary>
        /// Выполнить POST запрос.
        /// </summary>
        /// <param name="url"> URL. </param>
        /// <param name="parameters"> Параметры запроса. </param>
        /// <param name="webProxy"> Хост. </param>
        /// <returns> Результат </returns>
        public static WebCallResult PostCall(string url, IEnumerable <KeyValuePair <string, string> > parameters, IWebProxy webProxy)
        {
                        #if DEBUG_HTTP
            LogWebCallRequestInfo("POST", url, parameters, webProxy);
            var watch = System.Diagnostics.Stopwatch.StartNew();
                        #endif

            using (var call = new WebCall(url: url, cookies: new Cookies(), webProxy: webProxy))
            {
                var response = call._request
                               .PostAsync(requestUri: url, content: new FormUrlEncodedContent(nameValueCollection: parameters))
                               .Result;
                var res = call.MakeRequest(response: response, uri: new Uri(uriString: url), webProxy: webProxy);

                                #if DEBUG_HTTP
                watch.Stop();
                LogWebCallResultDebugInfo("POST", url, response, res, watch.ElapsedMilliseconds);
                                #endif

                return(res);
            }
        }
예제 #15
0
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url"> URL. </param>
        /// <param name="webProxy"> Хост. </param>
        /// <returns> Результат </returns>
        private WebCallResult RedirectTo(string url, IWebProxy webProxy = null)
        {
                #if DEBUG_HTTP
            LogWebCallRequestInfo("REDIRECT GET", url, null, webProxy);
            var watch = System.Diagnostics.Stopwatch.StartNew();
                        #endif

            using (var call = new WebCall(url: url, cookies: _result.Cookies, webProxy: webProxy))
            {
                var headers = call._request.DefaultRequestHeaders;
                headers.Add(name: "Method", value: "GET");
                headers.Add(name: "ContentType", value: "text/html");

                var response = call._request.GetAsync(requestUri: url).Result;
                var res      = call.MakeRequest(response: response, uri: new Uri(uriString: url), webProxy: webProxy);

                        #if DEBUG_HTTP
                watch.Stop();
                LogWebCallResultDebugInfo("REDIRECT GET", url, response, res, watch.ElapsedMilliseconds);
                                #endif

                return(res);
            }
        }
예제 #16
0
        /// <summary>
        /// Post запрос из формы.
        /// </summary>
        /// <param name="form"> Форма. </param>
        /// <param name="webProxy"> Хост. </param>
        /// <returns> Результат </returns>
        public static WebCallResult Post(WebForm form, IWebProxy webProxy)
        {
                        #if DEBUG_HTTP
            LogWebCallRequestInfo("POST", form.ActionUrl, form.GetFormFields(), webProxy);
            var watch = System.Diagnostics.Stopwatch.StartNew();
                        #endif

            using (var call = new WebCall(url: form.ActionUrl, cookies: form.Cookies, webProxy: webProxy, allowAutoRedirect: false))
            {
                SpecifyHeadersForFormRequest(form: form, call: call);

                var response = call._request
                               .PostAsync(requestUri: form.ActionUrl, content: new FormUrlEncodedContent(nameValueCollection: form.GetFormFields()))
                               .Result;
                var res = call.MakeRequest(response: response, uri: new Uri(uriString: form.ActionUrl), webProxy: webProxy);

                                #if DEBUG_HTTP
                watch.Stop();
                LogWebCallResultDebugInfo("POST", form.ActionUrl, response, res, watch.ElapsedMilliseconds);
                                #endif

                return(res);
            }
        }
예제 #17
0
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        public static WebCallResult MakeCall(string url, IWebProxy webProxy = null)
        {
            var call = new WebCall(url, new Cookies(), webProxy);

            return(call.MakeRequest(webProxy));
        }
예제 #18
0
파일: WebCall.cs 프로젝트: vknet/vk
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        public static WebCallResult MakeCall(string url, IWebProxy webProxy = null)
        {
            var call = new WebCall(url, new Cookies(), webProxy);

            return call.MakeRequest(webProxy);
        }
예제 #19
0
        public static WebCallResult MakeCall(string url)
        {
            var call = new WebCall(url, new Cookies());

            return(call.MakeRequest());
        }
예제 #20
0
파일: WebCall.cs 프로젝트: SaintCat/VkBot
        public static WebCallResult MakeCall(string url, VkApi vk)
        {
            var call = new WebCall(url, new Cookies(), vk);

            return call.MakeRequest(vk);
        }
예제 #21
0
파일: WebCall.cs 프로젝트: vknet/vk
        /// <summary>
        /// Post запрос из формы.
        /// </summary>
        /// <param name="form">Форма.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        public static WebCallResult Post(WebForm form, IWebProxy webProxy)
        {
            using (var call = new WebCall(form.ActionUrl, form.Cookies, webProxy, false))
            {
                var formRequest = form.GetRequest();

                var headers = call._request.DefaultRequestHeaders;
                headers.Add("Method", "POST");
                headers.Add("ContentType", "application/x-www-form-urlencoded");

                headers.Add("ContentLength", formRequest.Length.ToString());
                headers.Referrer = new Uri(form.OriginalUrl);

                var paramList = new Dictionary<string, string>();
                foreach (var param in form.GetRequestAsStringArray())
                {
                    if (paramList.ContainsKey(param))
                    {
                        continue;
                    }

                    var paramPair = param.Split('=');
                    var key = paramPair[0] + "";
                    var value = paramPair[1] + "";
                    paramList.Add(key, value);
                }

                var request = call._request.PostAsync(form.ActionUrl, new FormUrlEncodedContent(paramList)).Result;
                return call.MakeRequest(request, new Uri(form.ActionUrl), webProxy);
            }
        }
예제 #22
0
파일: WebCall.cs 프로젝트: kadkin/vk
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        private WebCallResult RedirectTo(string url, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, Result.Cookies, host, port, proxyLogin, proxyPassword);

            var request = call.Request;
            request.Method = "GET";
            request.ContentType = "text/html";
            request.Referer = Request.Referer;

            return call.MakeRequest(host, port, proxyLogin, proxyPassword);
        }
예제 #23
0
파일: WebCall.cs 프로젝트: kadkin/vk
        /// <summary>
        /// Выполнить POST запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="parameters">Параметры запроса.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        public static WebCallResult PostCall(string url, string parameters, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, new Cookies(), host, port, proxyLogin, proxyPassword)
            {
                Request =
                {
                    Method = "POST",
                    ContentType = "application/x-www-form-urlencoded"
                }
            };

            var data = Encoding.UTF8.GetBytes(parameters);
            call.Request.ContentLength = data.Length;

            using (var requestStream = call.Request.GetRequestStream())
                requestStream.Write(data, 0, data.Length);

            return call.MakeRequest(host, port, proxyLogin, proxyPassword);
        }
예제 #24
0
파일: WebCall.cs 프로젝트: ProESM/vk
        public static WebCallResult MakeCall(string url, string host = null, int? port = null)
        {
            var call = new WebCall(url, new Cookies(), host, port);

            return call.MakeRequest(host, port);
        }
예제 #25
0
파일: WebCall.cs 프로젝트: vknet/vk
        /// <summary>
        /// Пере адресация.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        private WebCallResult RedirectTo(string url, IWebProxy webProxy = null)
        {
            using (var call = new WebCall(url, _result.Cookies, webProxy))
            {
                var headers = call._request.DefaultRequestHeaders;
                headers.Add("Method", "GET");
                headers.Add("ContentType", "text/html");

                var response = call._request.GetAsync(url).Result;

                return call.MakeRequest(response, new Uri(url), webProxy);
            }
        }
예제 #26
0
파일: WebCall.cs 프로젝트: kadkin/vk
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        public static WebCallResult MakeCall(string url, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, new Cookies(), host, port, proxyLogin, proxyPassword);

            return call.MakeRequest(host, port, proxyLogin, proxyPassword);
        }
예제 #27
0
파일: WebCall.cs 프로젝트: faruk63/vk
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        public static WebCallResult MakeCall(string url, string host = null, int?port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(url, new Cookies(), host, port, proxyLogin, proxyPassword);

            return(call.MakeRequest(host, port, proxyLogin, proxyPassword));
        }
예제 #28
0
파일: WebCall.cs 프로젝트: kadkin/vk
        /// <summary>
        /// Post запрос из формы.
        /// </summary>
        /// <param name="form">Форма.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <param name="proxyLogin">Логин прокси-сервера</param>
        /// <param name="proxyPassword">Пароль прокси-сервера</param>
        /// <returns>Результат</returns>
        public static WebCallResult Post(WebForm form, string host = null, int? port = null, string proxyLogin = null, string proxyPassword = null)
        {
            var call = new WebCall(form.ActionUrl, form.Cookies, host, port, proxyLogin, proxyPassword);

            var request = call.Request;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            var formRequest = form.GetRequest();
            request.ContentLength = formRequest.Length;
            request.Referer = form.OriginalUrl;
            request.GetRequestStream().Write(formRequest, 0, formRequest.Length);
            request.AllowAutoRedirect = false;

            return call.MakeRequest(host, port, proxyLogin, proxyPassword);
        }
예제 #29
0
파일: WebCall.cs 프로젝트: nijikilling/vk
        /// <summary>
        /// Выполнить запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="host">Хост.</param>
        /// <param name="port">Порт.</param>
        /// <returns>Результат</returns>
        public static WebCallResult MakeCall(string url, string host = null, int?port = null)
        {
            var call = new WebCall(url, new Cookies(), host, port);

            return(call.MakeRequest(host, port));
        }
예제 #30
0
파일: WebCall.cs 프로젝트: vknet/vk
        /// <summary>
        /// Выполнить POST запрос.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="parameters">Параметры запроса.</param>
        /// <param name="webProxy">Хост.</param>
        /// <returns>Результат</returns>
        public static WebCallResult PostCall(string url, string parameters, IWebProxy webProxy)
        {
            using (var call = new WebCall(url, new Cookies(), webProxy))
            {
                var data = Encoding.UTF8.GetBytes(parameters);

                var headers = call._request.DefaultRequestHeaders;
                headers.Add("Method", "POST");
                headers.Add("ContentType", "application/x-www-form-urlencoded");
                headers.Add("ContentLength", data.Length.ToString());

                var paramList = new Dictionary<string, string>();
                foreach (var param in parameters.Split('&'))
                {
                    if (paramList.ContainsKey(param))
                    {
                        continue;
                    }

                    var paramPair = param.Split('=');
                    var key = paramPair[0] + "";
                    var value = paramPair[1] + "";
                    paramList.Add(key, value);
                }

                var request = call._request.PostAsync(url, new FormUrlEncodedContent(paramList)).Result;
                return call.MakeRequest(request, new Uri(url), webProxy);
            }
        }