static void Main(string[] args) { string request = new RandomGoogleSearchMessageBuilder().Build(); var post = new HttpPost("http://www.ghettodriveby.com/soap/index.php", request, "text/xml", "utf-8"); post.AddHeader("SOAPAction", "urn:RandomGoogleSearch#RandomGoogleSearch#getRandomGoogleSearch"); var response = new HttpGateway().Execute(post); var document = new XmlDocument(response.Content); var image = document.GetNode("//image").GetValue(); Console.WriteLine("image:" + image); Console.ReadLine(); }
public void should_parse_response_for_get_request() { var server = new WebServer((request, responseStream) => { responseStream.WriteLine("HTTP/1.1 200 OK"); responseStream.WriteLine(""); responseStream.Write("yeah"); }); server.Start(); var response = new HttpGateway().Execute(new HttpGet(string.Format("http://localhost:{0}", server.PortNumber))); Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK)); Assert.That(response.StatusDescription, Is.EqualTo("OK")); Assert.That(response.Content, Is.EqualTo("yeah")); Assert.That(response.Failed, Is.False); }
public void should_return_failed_response_when_server_returns_internal_server_error_on_post_request() { var server = new WebServer((request, responseStream) => { responseStream.WriteLine("HTTP/1.1 500 Internal Server Error"); responseStream.WriteLine(""); responseStream.Write("i just dont know what to do with myself..."); }); server.Start(); var uri = "http://localhost:" + server.PortNumber; var response = new HttpGateway().Execute(new HttpPost(uri, "test.data", "text/xml", "utf-8")); Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError)); Assert.That(response.StatusDescription, Is.EqualTo("Internal Server Error")); Assert.That(response.Content, Is.EqualTo("i just dont know what to do with myself...")); Assert.That(response.Failed, Is.True); }