public override void CheckFaults(HttpOperation operation, HttpResponse response) { if (!response.Request.RequestModelResult.Headers.ContainsKey("Accept") || !response.Headers.ContainsKey("Content-Type")) { return; } string text = response.Request.RequestModelResult.Headers["Accept"].ToLower(); string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); string text2 = response.Headers["Content-Type"].ToLower(); for (int i = 0; i < array.Length; i++) { array[i] = array[i].Trim(); if (array[i].Contains("/*")) { array[i] = array[i].Remove(array[i].IndexOf("/*"), array[i].Length - array[i].IndexOf("/*")); } if (array[i] == "*" || text2.StartsWith(array[i])) { return; } } operation.Fault("Unexpected media type. Expected '" + text + "' but received '" + text2 + "'."); }
public override void CheckFaults(HttpOperation operation, HttpResponse response) { if (!response.Is2XX && !response.Is100) { operation.Fault("Response status code is not 100, 200-299."); } }
public override void CheckFaults(HttpOperation operation, HttpResponse response) { if (response.StatusCode != HttpStatusCode.OK) { operation.Fault("Response status code is not 200."); } }
public override void CheckFaults(HttpOperation operation, HttpResponse response) { string[] array = FieldName.Split(new char[1] { '.' }, StringSplitOptions.RemoveEmptyEntries); FieldInfo fieldInfo = null; object obj = operation; string[] array2 = array; foreach (string text in array2) { if (obj == null) { break; } fieldInfo = obj.GetType().GetField(text, BindingFlags.Instance | BindingFlags.Public); if (fieldInfo == null) { throw new NotSupportedException("HttpFaultWhen could not find '" + text + "' field when parsing '" + FieldName + "'"); } obj = fieldInfo.GetValue(obj); } switch (FieldOperator) { case HttpFaultWhenCondition.Is: if (object.Equals(obj, FieldValue)) { operation.Fault("Field '" + FieldName + "' is " + ((FieldValue != null) ? FieldValue.ToString() : "(null)") + " on response."); } break; case HttpFaultWhenCondition.IsNot: if (!object.Equals(obj, FieldValue)) { operation.Fault("Field '" + FieldName + "' is not " + ((FieldValue != null) ? FieldValue.ToString() : "(null)") + " on response."); } break; } }