Пример #1
0
        public async Task <(bool IsSuccess, PageHeaders PageHeaders, string ErrorMsg)> FetchTargetHeadersAsync(string url)
        {
            try
            {
                // Fetch Headers for URL
                var httpClient = httpClientFactory.CreateClient("ZeroConfigClient");
                var response   = await httpClient.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);

                if (response.IsSuccessStatusCode)
                {
                    // @TODO: Introduce external mapper for Model
                    var headers = new PageHeaders();
                    headers.headers = new List <(string HeaderKey, IEnumerable <string> HeaderValues)>();

                    foreach (var header in response.Headers)
                    {
                        headers.headers.Add((header.Key, header.Value));
                    }

                    return(true, headers, null);
                }
                return(false, null, response.ReasonPhrase);
            }
            catch (Exception e)
            {
                logger?.LogError(e.ToString());
                return(false, null, e.Message);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the PDFPageHeader for the identified page and returns true if there is one.
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="header"></param>
        /// <returns></returns>
        internal bool GetHeaderForPage(int pageindex, out PDFPageHeader header)
        {
            PageAdornment adorn;

            if (null != PageHeaders && PageHeaders.TryGetValue(pageindex, out adorn))
            {
                header = (PDFPageHeader)adorn;
                return(true);
            }
            else
            {
                header = null;
                return(false);
            }
        }