private string GETResponseFrom(string url) { IHttpWebRequestProxy req = _httpFactory.Create(url); req.Method = "GET"; req.Headers["Cookie"] = AuthCookie; using (IHttpWebResponseProxy resp = req.GetResponse()) { using (Stream s = resp.GetResponseStream()) using (StreamReader sr = new StreamReader(s)) { return(sr.ReadToEnd()); } //end using } //end using }
private bool POSTTo(string url, string body) { IHttpWebRequestProxy req = _httpFactory.Create(url); req.Method = "POST"; req.Headers["Cookie"] = AuthCookie; req.ContentType = "application/x-www-form-urlencoded"; using (Stream reqStream = req.GetRequestStream()) using (StreamWriter strWriter = new StreamWriter(reqStream)) { strWriter.Write(body); } //end using //Grab response using (IHttpWebResponseProxy resp = req.GetResponse()) { return(resp.StatusCode == System.Net.HttpStatusCode.OK); } //end using }
private string GetAuthCookie() { //Set up request, including username and password in form data IHttpWebRequestProxy req = _httpFactory.Create(LOGINURL); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; using (Stream reqStream = req.GetRequestStream()) using (StreamWriter strWriter = new StreamWriter(reqStream)) { strWriter.Write(String.Format("login={0}&password={1}", _userName, _password)); } //end using //Grab response using (IHttpWebResponseProxy resp = req.GetResponse()) { return(resp.Headers["Set-Cookie"]); } //end using }