示例#1
0
 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" };
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
 private static void setContentHeaders(HttpResponseMessage response, ResourceFormat format)
 {
     response.Content.Headers.ContentType = FhirMediaType.GetMediaTypeHeaderValue(typeof(Resource), format);
 }
示例#6
0
 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" };
 }