Esempio n. 1
0
        public async Task <string> Get(AiurUrl url, bool internalRequest)
        {
            HttpWebRequest request = null;

            if (internalRequest)
            {
                url.Address = url.Address.Replace("https://", "http://");
                request     = WebRequest.CreateHttp(url.ToString());
                request.Headers.Add("x-request-origin", Values.ProjectName);
            }
            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));
        }
Esempio n. 2
0
        public async Task <string> Post(AiurUrl url, AiurUrl postDataStr, bool internalRequest)
        {
            HttpWebRequest request = null;

            if (internalRequest)
            {
                url.Address = url.Address.Replace("https://", "http://");
                request     = WebRequest.CreateHttp(url.ToString());
                request.Headers.Add("x-request-origin", Values.ProjectName);
            }
            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));
        }