public override TestResult Run(HttpClient client) { try { HttpResponse response = client.Request(Settings.GeneralPath, null, null, "GET", "HTTP/1.2"); if (response.StatusCode == 505) /* 505 HTTP Version Not Supported */ { return(TestResult.Passed); } if (response.StatusCode == 400) /* 400 Bad Request */ { return(Result400); } if (response.StatusCode >= 300 && response.StatusCode <= 399) { return(new TestResult(TestStatus.NonConformance, "The server has sent the status \"" + HttpStatuses.Format(response.StatusCode) + "\", to mitigate this problem, when it could've used the '" + Status500Formatted + "\" status.")); } return(new TestResult(TestStatus.NonConformance, "The server has sent the status \"" + HttpStatuses.Format(response.StatusCode) + "\", when \"" + HttpStatuses.Format(400) + "\" or the better \"" + Status500Formatted + "\" status was expected.")); } catch (Exception e) { return(new TestResult(TestStatus.Error, e.Message)); } }
public override TestResult Run(HttpClient client) { try { HttpResponse response = client.Request("*", null, null, "OPTIONS"); /*foreach (string name in response.Headers.Names) { * Console.Write("\tHeader> '{0}' => '{1}'\n", name, response.Headers[name]); * }*/ return(response.StatusCode < 400 ? TestResult.Passed : new TestResult(TestStatus.NotSupported, "The server doesn't support the OPTIONS header, as the server sent response status: " + HttpStatuses.Format(response.StatusCode))); } catch (Exception e) { return(new TestResult(TestStatus.Error, e.Message)); } }
public override TestResult Run(HttpClient client) { try { HttpResponse response = client.Request(Settings.GeneralPath, null, null, "GET", "ABCD/1.1"); if (response.StatusCode == 505) /* 505 HTTP Version Not Supported */ { return(TestResult.Passed); } if (response.StatusCode == 400) /* 400 Bad Request */ { return(Result400); } else { return(new TestResult(TestStatus.NonConformance, "The server has sent the status \"" + HttpStatuses.Format(response.StatusCode) + "\", when \"" + HttpStatuses.Format(400) + "\" or the better \"" + HttpStatuses.Format(505) + "\" status was expected.")); } } catch (Exception e) { return(new TestResult(TestStatus.Error, e.Message)); } }