using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace ProjetDotNet.web
{
    public class RequeteHTTP
    {
        private string _url;

        public RequeteHTTP(string url, string idPoint)
        {
            _url = url + "?idPoint=" + idPoint;
        }

        public RequeteHTTP(string url, string idPoint,string nomFigure)
        {
            _url = url + "?idPoint=" + idPoint + "&nomFigure="+nomFigure;
        }

        public string RecevoirHTTPResponse(HttpWebRequest wr)
        {
            using (HttpWebResponse resp = (HttpWebResponse)wr.GetResponse())
            {
                StreamReader sr = new StreamReader(resp.GetResponseStream());
                string val = sr.ReadToEnd();
                //Console.WriteLine(val);
                //Debug.WriteLine(val);
                //Console.ReadLine();)

                return val;
            }
        }

        public string LancerHTTPRequest()
        {
            string reponse;

            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(_url);
            System.Console.WriteLine(_url);

            reponse = RecevoirHTTPResponse(wr);

            return reponse;
        }


    }
}
