public void MethodNotAllowedOnHttpPut() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/get"); request.Method = HttpMethod.PUT; request.Content = Helper.StreamFromString("Should be ignored"); var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(405, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); } }
public void RequestUserAgentString() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/user-agent"); request.Method = HttpMethod.GET; var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(200, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); var stream = new StreamReader(response.Content); Assert.IsNotNull(stream); var content = stream.ReadToEnd(); Assert.IsTrue(content.Length > 0); Assert.AreEqual("{\n \"user-agent\": \"" + Info.Agent + "\"\n}", content); } }
public void StatusCode500OfHttpGetRequest() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/status/500"); request.Method = HttpMethod.GET; var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(500, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); } }
public void SimpleHttpPutRequest() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/put"); request.Method = HttpMethod.PUT; request.Content = Helper.StreamFromString("PUT THIS THING BACK"); var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(200, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); var stream = new StreamReader(response.Content); Assert.IsNotNull(stream); var content = stream.ReadToEnd(); Assert.IsTrue(content.Length > 0); Assert.IsTrue(content.Contains("\"data\": \"PUT THIS THING BACK\"")); } }
public void SimpleHttpGetRequest() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/robots.txt"); request.Method = HttpMethod.GET; var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(200, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); var content = new StreamReader(response.Content); Assert.AreEqual("User-agent: *\nDisallow: /deny\n", content.ReadToEnd()); } }
public void SimpleHttpDeleteRequest() { if (Helper.IsNetworkAvailable()) { var http = new DefaultHttpRequester(); var request = new DefaultHttpRequest(); request.Address = new Uri("http://httpbin.org/delete"); request.Method = HttpMethod.DELETE; request.Content = Helper.StreamFromString("Should be ignored"); var response = http.Request(request); Assert.IsNotNull(response); Assert.AreEqual(200, (int)response.StatusCode); Assert.IsTrue(response.Content.CanRead); Assert.IsTrue(response.Headers.Count > 0); } }