public override void WriteResponseHeaders(OutputFormatterWriteContext context) { context.ContentType = FhirMediaType.GetMediaTypeHeaderValue(context.ObjectType, ResourceFormat.Xml); // note that the base is called last, as this may overwrite the ContentType where the resource is of type Binary base.WriteResponseHeaders(context); // headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "fhir.resource.json" }; }
public static MediaTypeHeaderValue GetMediaTypeHeaderValue(Type type, ResourceFormat format) { string mediatype = FhirMediaType.GetContentType(type, format); MediaTypeHeaderValue header = new MediaTypeHeaderValue(mediatype); header.CharSet = Encoding.UTF8.WebName; return(header); }
public static StringSegment GetMediaTypeHeaderValue(Type type, ResourceFormat format) { string mediatype = FhirMediaType.GetContentType(type, format); MediaTypeHeaderValue header = new MediaTypeHeaderValue(mediatype); header.CharSet = Encoding.UTF8.WebName; // return header; StringSegment hv = new StringSegment(header.ToString()); return(hv); }
private bool isBinaryRequest(HttpRequestMessage request) { var format = FhirMediaType.Interpret(request.Content != null && request.Content.Headers != null && request.Content.Headers.ContentType != null ? request.Content.Headers.ContentType.MediaType : "Unknown"); if (format != FhirMediaType.JsonResource && format != FhirMediaType.XmlResource) { if (format == FhirMediaType.BinaryResource) { return(true); } var ub = new UriBuilder(request.RequestUri); return(ub.Path.Contains("/Binary")); // todo: replace quick hack by solid solution. } return(false); }
private static void setContentHeaders(HttpResponseMessage response, ResourceFormat format) { response.Content.Headers.ContentType = FhirMediaType.GetMediaTypeHeaderValue(typeof(Resource), format); }
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType) { base.SetDefaultContentHeaders(type, headers, mediaType); headers.ContentType = FhirMediaType.GetMediaTypeHeaderValue(type, ResourceFormat.Json); // headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "fhir.resource.json" }; }