Esempio n. 1
0
        public string SubmitRequest(PocketWebRequest request)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(request.Url);

            httpWebRequest.Method      = request.RequestMethod;
            httpWebRequest.ContentType = request.ContentyType;

            if (request.RequestMethod != WebRequestMethods.Http.Get)
            {
                using (var requestStream = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    requestStream.Write(request.Request);
                }
            }

            var    response = (HttpWebResponse)httpWebRequest.GetResponse();
            string result;

            using (var rdr = new StreamReader(response.GetResponseStream()))
            {
                result = rdr.ReadToEnd();
            }

            return(result);
        }
Esempio n. 2
0
        public string SubmitRequest(PocketWebRequest request)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(request.Url);
            httpWebRequest.Method = request.RequestMethod;
            httpWebRequest.ContentType = request.ContentyType;

            if (request.RequestMethod != WebRequestMethods.Http.Get)
            {
                using (var requestStream = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    requestStream.Write(request.Request);
                }
            }

            var response = (HttpWebResponse)httpWebRequest.GetResponse();
            string result;
            using ( var rdr = new StreamReader(response.GetResponseStream()))
            {
                result = rdr.ReadToEnd();
            }

            return result;
        }