internal static void AcquireHeaders(this HttpResponseMessage response, FhirResponse fhirResponse)
        {
            if (fhirResponse.Key != null)
            {
                response.Headers.ETag = ETag.Create(fhirResponse.Key.VersionId);

                Uri location = fhirResponse.Key.ToUri();
                response.Headers.Location = location;

                if (response.Content != null)
                {
                    response.Content.Headers.ContentLocation = location;
                    if (fhirResponse.Resource != null && fhirResponse.Resource.Meta != null)
                    {
                        response.Content.Headers.LastModified = fhirResponse.Resource.Meta.LastUpdated;
                    }
                }
            }
        }
        internal static void AcquireHeaders(this HttpResponse response, FhirResponse fhirResponse)
        {
            if (fhirResponse.Key != null)
            {
                response.Headers.Add("ETag", ETag.Create(fhirResponse.Key.VersionId)?.ToString());

                Uri location = fhirResponse.Key.ToUri();
                response.Headers.Add("Location", location.OriginalString);

                if (response.Body != null)
                {
                    response.Headers.Add("Content-Location", location.OriginalString);
                    if (fhirResponse.Resource != null && fhirResponse.Resource.Meta != null)
                    {
                        response.Headers.Add("Last-Modified", fhirResponse.Resource.Meta.LastUpdated.Value.ToString("R"));
                    }
                }
            }
        }
Example #3
0
        public static Bundle.EntryComponent TranslateToSparseEntry(this Entry entry, FhirResponse response = null)
        {
            var bundleEntry = new Bundle.EntryComponent();

            if (response != null)
            {
                bundleEntry.Response = new Bundle.ResponseComponent()
                {
                    Status                         = string.Format("{0} {1}", (int)response.StatusCode, response.StatusCode),
                    Location                       = response.Key != null?response.Key.ToString() : null,
                                              Etag = response.Key != null?ETag.Create(response.Key.VersionId).ToString() : null,
                                                         LastModified =
                                                             (entry != null && entry.Resource != null && entry.Resource.Meta != null)
                            ? entry.Resource.Meta.LastUpdated
                            : null
                };
            }

            SetBundleEntryResource(entry, bundleEntry);
            return(bundleEntry);
        }
Example #4
0
        //public static HttpResponseMessage HttpResponse(this HttpRequestMessage request, HttpStatusCode code, Entry entry)
        //{
        //    request.SaveEntry(entry);

        //    HttpResponseMessage msg;
        //    msg = request.CreateResponse<Resource>(code, entry.Resource);

        //    // DSTU2: tags
        //    //msg.Headers.SetFhirTags(entry.Tags);
        //    return msg;
        //}



        public static void AcquireHeaders(this HttpResponseMessage response, FhirResponse fhirResponse)
        {
            // http.StatusCode = fhir.StatusCode;
            if (fhirResponse.Key != null)
            {
                response.Headers.ETag = ETag.Create(fhirResponse.Key.VersionId);

                Uri location = fhirResponse.Key.ToUri();

                if (response.Content != null)
                {
                    response.Content.Headers.ContentLocation = location;
                }
                else
                {
                    response.Headers.Location = location;
                }
            }

            if (fhirResponse.Resource != null && fhirResponse.Resource.Meta != null)
            {
                response.Content.Headers.LastModified = fhirResponse.Resource.Meta.LastUpdated;
            }
        }