internal static bool IsRawBinaryRequest(this OutputFormatterCanWriteContext context, Type type)
        {
            if (type == typeof(Binary) || (type == typeof(FhirResponse)) && ((FhirResponse)context.Object).Resource is Binary)
            {
                HttpRequest request         = context.HttpContext.Request;
                bool        isFhirMediaType = false;
                if (request.Method == "GET")
                {
                    isFhirMediaType = request.IsAcceptHeaderFhirMediaType();
                }
                else if (request.Method == "POST" || request.Method == "PUT")
                {
                    isFhirMediaType = HttpRequestExtensions.IsContentTypeHeaderFhirMediaType(request.ContentType);
                }

                var ub = new UriBuilder(request.GetRequestUri());
                // TODO: KM: Path matching is not optimal should be replaced by a more solid solution.
                return(ub.Path.Contains("Binary") &&
                       !isFhirMediaType);
            }
            else
            {
                return(false);
            }
        }
        internal static bool IsRawBinaryPostOrPutRequest(this HttpRequest request)
        {
            var ub = new UriBuilder(request.GetRequestUri());

            // TODO: KM: Path matching is not optimal should be replaced by a more solid solution.
            return(ub.Path.Contains("Binary") &&
                   !HttpRequestExtensions.IsContentTypeHeaderFhirMediaType(request.ContentType) &&
                   (request.Method == "POST" || request.Method == "PUT"));
        }