protected virtual void RefreshAccept() { ResourceProperty property = GetPropertyFromQuery(); bool propertyUri = (property != null && !property.IsNavigation && !(property.Type is CollectionType)); bool valueUri = URI_Internal.Contains("$value"); bool linksUri = URI_Internal.Contains("$ref"); if (valueUri) { Accept_Internal = null; } else if (this.MetadataOnly) { Accept_Internal = "*/*"; } else if ((propertyUri || linksUri) && (Format == SerializationFormatKind.Atom || Format == SerializationFormatKind.Default)) { Accept_Internal = "application/xml"; } else if (Format == SerializationFormatKind.JSON) { Accept_Internal = ApplicationJson + ";odata.metadata=verbose"; } else { Accept_Internal = SerializationFormatKinds.ContentTypeFromKind(Format); } Accept_Internal = RequestUtil.RandomizeContentTypeCapitalization(Accept_Internal); }
public virtual HttpStatusCode DefaultExpectedStatusCode() { RequestVerb verb; if (TunnelledVerb_Internal.HasValue) { verb = TunnelledVerb_Internal.Value; } else { verb = Verb_Internal; } HttpStatusCode code; switch (verb) { case RequestVerb.Get: code = HttpStatusCode.OK; break; case RequestVerb.Put: case RequestVerb.Patch: case RequestVerb.Delete: code = HttpStatusCode.NoContent; break; case RequestVerb.Post: if (URI_Internal.Contains("$ref")) { code = HttpStatusCode.NoContent; } else if (URI_Internal.Contains("$batch")) { code = HttpStatusCode.Accepted; } else { code = HttpStatusCode.Created; } break; default: code = HttpStatusCode.NotImplemented; break; } return(code); }
protected virtual void RefreshContentType() { if (Payload == null && (Verb_Internal == RequestVerb.Get || Verb_Internal == RequestVerb.Delete)) { ContentType_Internal = null; } else { ResourceProperty property = GetPropertyFromQuery(); bool propertyUri = (property != null && !property.IsNavigation && !(property.Type is CollectionType)); bool valueUri = URI_Internal.Contains("$value"); bool linksUri = URI_Internal.Contains("$ref"); if (propertyUri && !property.IsComplexType && valueUri) { if (property.Type.ClrType == typeof(byte[])) { ContentType_Internal = SerializationFormatKinds.MimeApplicationOctetStream; } else { ContentType_Internal = SerializationFormatKinds.MimeTextPlain; } } else if (propertyUri && !valueUri && (Format == SerializationFormatKind.Atom || Format == SerializationFormatKind.Default)) { ContentType_Internal = SerializationFormatKinds.MimeApplicationXml; } else if (linksUri && (Format == SerializationFormatKind.Atom || Format == SerializationFormatKind.Default)) { ContentType_Internal = "application/xml"; } else if (Format == SerializationFormatKind.JSON) { ContentType_Internal = ApplicationJson + ";odata.metadata=verbose"; } else { ContentType_Internal = SerializationFormatKinds.ContentTypeFromKind(Format); } ContentType_Internal = RequestUtil.RandomizeContentTypeCapitalization(ContentType_Internal); } }