예제 #1
0
 private void AddIfMissing(HttpResponseHeaders headers, string header, string value)
 {
     if (!headers.Contains(header))
     {
         headers.Add(header, value);
     }
 }
예제 #2
0
        public static PagingInfo FindAndParsePagingInfo(HttpResponseHeaders responseHeaders)
        {
            // find the "X-Pagination" info in header
            if (responseHeaders.Contains("X-Pagination"))
            {
                var xPag = responseHeaders.First(ph => ph.Key == "X-Pagination").Value;

                // parse the value - this is a JSON-string.
                return JsonConvert.DeserializeObject<PagingInfo>(xPag.First());
            }
            return null;
        }
예제 #3
0
        public static PaginationInfo FindAndParsePaginationInfo(HttpResponseHeaders responseHeaders)
        {
            //find x-pagination
            if (responseHeaders.Contains("X-Pagination"))
            {
                var xPag = responseHeaders.First(rh => rh.Key == "X-Pagination").Value;
                return JsonConvert.DeserializeObject<PaginationInfo>(xPag.First());

            }

            return null;
        }
예제 #4
0
파일: Pages.cs 프로젝트: nikmd23/signatory
        public Pages(HttpResponseHeaders headers)
        {
            if (headers.Contains("Link"))
            {
                var links = headers.ParseLinkHeaders(new Uri("https://api.github.com/"), new LinkRegistry());

                var nextLink = links.SingleOrDefault(link => link.Relation == "next");
                var firstLink = links.SingleOrDefault(link => link.Relation == "first");
                var lastLink = links.SingleOrDefault(link => link.Relation == "last");
                var previousLink = links.SingleOrDefault(link => link.Relation == "prev");

                if (nextLink != null) Next = Convert.ToInt32(nextLink.Target.ParseQueryString()["page"]);
                if (firstLink != null) First = Convert.ToInt32(firstLink.Target.ParseQueryString()["page"]);
                if (lastLink != null) Last = Convert.ToInt32(lastLink.Target.ParseQueryString()["page"]);
                if (previousLink != null) Previous = Convert.ToInt32(previousLink.Target.ParseQueryString()["page"]);
            }
        }
예제 #5
0
        private void CheckResponseHeaders(HttpResponseHeaders headers)
        {
            var xHeader = "";
            if (headers.Contains("X-Atmosphere-tracking-id"))
            {
                xHeader = headers.GetValues("X-Atmosphere-tracking-id").FirstOrDefault();
            }

            if (!Equals(xHeader, X_Atmosphere_tracking_id))
            {
                X_Atmosphere_tracking_id = xHeader;
            }
        }
예제 #6
0
 public static int? ParseFirstValue(string header, HttpResponseHeaders headers)
 {
     IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
     return GetIntValue(value);
 }
예제 #7
0
 public static string GetHeaderValue(string header, HttpResponseHeaders headers)
 {
     IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
     return GetStringValue(value);
 }