Example #1
0
        public void TagHeaderParsing()
        {
            string tag1 = @"http://furore.com/tags/test1; label = ""yes""; scheme=""http://hl7.org/fhir/tag""";
            string tag2 = @"http://furore.com/tags/test1; scheme=""http://hl7.org/fhir/tag""; label = ""confusion, abounds - beyond!"";";
            string tag3 = @"dog; label=""Canine""; scheme=""http://purl.org/net/animals""";

            string tags = tag1 + ", " + tag2 + " , " + tag3;

            var parsedTags = HttpUtil.ParseCategoryHeader(tags);

            Assert.AreEqual(3, parsedTags.Count());

            var t1 = parsedTags.First();

            Assert.AreEqual("yes", t1.Label);
            Assert.AreEqual("http://furore.com/tags/test1", t1.Term);

            var t2 = parsedTags.Skip(1).First();

            Assert.AreEqual(@"confusion, abounds - beyond!", t2.Label);
            Assert.AreEqual("http://furore.com/tags/test1", t2.Term);

            string cat = HttpUtil.BuildCategoryHeader(parsedTags.FilterByScheme(Tag.FHIRTAGSCHEME_GENERAL));

            Assert.AreEqual(@"http://furore.com/tags/test1; label=""yes""; scheme=""http://hl7.org/fhir/tag"", http://furore.com/tags/test1; " +
                            @"label=""confusion, abounds - beyond!""; scheme=""http://hl7.org/fhir/tag""", cat);
        }
Example #2
0
        public void TagHeaderParsing()
        {
            string tag1 = @"http://furore.com/tags/test1; label = yes; scheme=""http://hl7.org/fhir/tag""";
            string tag2 = @"http://furore.com/tags/test1; scheme=""http://hl7.org/fhir/tag""; label = ""confusion"";";
            string tag3 = @"dog; label=""Canine""; scheme=""http://purl.org/net/animals""";

            string tags = tag1 + ", " + tag2 + " , " + tag3;

            var parsedTags = HttpUtil.ParseCategoryHeader(tag1);

            Assert.AreEqual(1, parsedTags.Count());

            parsedTags = HttpUtil.ParseCategoryHeader(tags);
            Assert.AreEqual(2, parsedTags.Count());
            var t1 = parsedTags.First();

            Assert.AreEqual("yes", t1.Label);
            Assert.AreEqual("http://furore.com/tags/test1", t1.Uri.ToString());
            var t2 = parsedTags.Skip(1).First();

            Assert.AreEqual(@"""confusion""", t2.Label);
            Assert.AreEqual("http://furore.com/tags/test1", t2.Uri.ToString());

            string cat = HttpUtil.BuildCategoryHeader(parsedTags);

            Assert.AreEqual(@"http://furore.com/tags/test1; label=yes; scheme=""http://hl7.org/fhir/tag"", http://furore.com/tags/test1; " +
                            @"label=""confusion""; scheme=""http://hl7.org/fhir/tag""", cat);
        }
Example #3
0
        private void prepareRequest(HttpWebRequest request, byte[] data, IEnumerable <Tag> tags = null)
        {
            if (tags != null)
            {
                request.Headers[HttpUtil.CATEGORY] = HttpUtil.BuildCategoryHeader(tags);
            }

#if NETFX_CORE
            var getStreamTask = request.GetRequestStreamAsync();
            getStreamTask.RunSynchronously();
            Stream outs = getStreamTask.Result;
#else
            Stream outs = request.GetRequestStream();
#endif

            outs.Write(data, 0, (int)data.Length);
            outs.Flush();

#if !NETFX_CORE
            outs.Close();
#endif
        }
Example #4
0
        public static void SetFhirTags(this HttpHeaders headers, IEnumerable <Tag> tags)
        {
            string tagstring = HttpUtil.BuildCategoryHeader(tags);

            headers.Add(FhirHeader.CATEGORY, tagstring);
        }