示例#1
0
        public async Task <string> Get(AiurUrl Url)
        {
            var request = WebRequest.CreateHttp(Url.ToString());

            request.CookieContainer = CC;
            request.Method          = "GET";
            request.ContentType     = "text/html;charset=utf-8";
            return(await HTTPMethods.ReadFromResponseAsync(request));
        }
示例#2
0
        public async Task <string> Post(AiurUrl Url, AiurUrl postDataStr)
        {
            var request = WebRequest.CreateHttp(Url.ToString());

            request.CookieContainer = CC;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";
            await HTTPMethods.SendRequestAsync(request, postDataStr.ToString().TrimStart('?'));

            return(await HTTPMethods.ReadFromResponseAsync(request));
        }
示例#3
0
        public async Task <string> Get(AiurUrl url, bool internalRequest = false)
        {
            HttpWebRequest request = null;

            if (internalRequest)
            {
                url.Address = url.Address.Replace("https://", "http://");
                request     = WebRequest.CreateHttp(url.ToString());
                request.Headers.Add("x-forwarded-for", "localhost");
            }
            else
            {
                request = WebRequest.CreateHttp(url.ToString());
            }
            _logger.LogInformation($"Creating HTTP GET request to: {request.RequestUri.ToString()}");
            request.CookieContainer = _cc;
            request.Method          = "GET";
            request.ContentType     = "text/html;charset=utf-8";
            return(await HTTPMethods.ReadFromResponseAsync(request));
        }
示例#4
0
        public async Task <string> Post(AiurUrl url, AiurUrl postDataStr, bool internalRequest = false)
        {
            HttpWebRequest request = null;

            if (internalRequest)
            {
                url.Address = url.Address.Replace("https://", "http://");
                request     = WebRequest.CreateHttp(url.ToString());
                request.Headers.Add("x-forwarded-for", "localhost");
            }
            else
            {
                request = WebRequest.CreateHttp(url.ToString());
            }
            _logger.LogInformation($"Creating HTTP Post request to: {request.RequestUri.ToString()}");
            request.CookieContainer = _cc;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";
            await HTTPMethods.SendRequestAsync(request, postDataStr.ToString().TrimStart('?'));

            return(await HTTPMethods.ReadFromResponseAsync(request));
        }