当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestHeaders.GetValues方法代码示例

本文整理汇总了C#中System.Net.Http.Headers.HttpRequestHeaders.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestHeaders.GetValues方法的具体用法?C# HttpRequestHeaders.GetValues怎么用?C# HttpRequestHeaders.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.Headers.HttpRequestHeaders的用法示例。


在下文中一共展示了HttpRequestHeaders.GetValues方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _GetCanonicalizedHeaders

 private string _GetCanonicalizedHeaders(HttpRequestHeaders headers)
 {
     var orderedHeaders = headers.OrderBy(x => x.Key);
     var headersWithAggregatedValues = orderedHeaders.Where(x => x.Key.StartsWith("x-ms")).Select(x => x.Key.ToLowerInvariant() + ":" + headers.GetValues(x.Key).Aggregate((x1, x2) => x1 + "," + x2));
     var canonicalHeader = headersWithAggregatedValues.Aggregate((x1, x2) => x1 + "\n" + x2) + "\n";
     return canonicalHeader;
 }
开发者ID:awithy,项目名称:AzureStorage,代码行数:7,代码来源:AuthorizationHeaderBuilder.cs

示例2: Authentication

        /// <summary>
        /// Authorization request header from client.
        /// </summary>
        /// <param name="header">header from client</param>
        /// <returns>-401/-403/{userId}</returns>
        public static long Authentication(HttpRequestHeaders header)
        {
            string authorization = header.GetValues("Authorization").FirstOrDefault();
            if (authorization == null)
                {
                    return -401;
                }
            using (var db = new CF_FamsamEntities())
            {
                string token = authorization.Split(null)[1];
                    Session session = db.Session.Find(token);
                    Debug.WriteLine("____________________________" + session.token);
                    if (session == null) return -403;

                    if (session.expired < DateTime.Now)
                    {
                        Debug.WriteLine("____________________________ session mili:" + session.expired.Millisecond);
                        Debug.WriteLine("____________________________ now mili:" + DateTime.Now.Millisecond);
                        //session expired
                        db.Session.Remove(session);
                        db.SaveChanges();
                        return -403;
                    }
                    else
                    {
                        return session.User.id;
                    }


                

            }
        }
开发者ID:sivarajankumar,项目名称:famsam,代码行数:38,代码来源:UserDAO.cs

示例3: AuthenticateUser

 public static bool AuthenticateUser(HttpRequestHeaders HttpHeaders)
 {
     if (HttpHeaders.Contains(HttpRequestHeaderName))
     {
         var authHeader = HttpHeaders.GetValues(HttpRequestHeaderName).First();
         return _authenticateHeaderValue(authHeader);
     }
     return false;
 }
开发者ID:jerroydmoore,项目名称:Cerberus,代码行数:9,代码来源:BasicAuth.cs

示例4: ParseFirstValue

 public static int? ParseFirstValue(string header, HttpRequestHeaders headers)
 {
     IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
     return GetIntValue(value);
 }
开发者ID:kevinwrightleft,项目名称:mozu-dotnet,代码行数:5,代码来源:HttpHelper.cs

示例5: GetHeaderValue

 public static string GetHeaderValue(string header, HttpRequestHeaders headers)
 {
     IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
     return GetStringValue(value);
 }
开发者ID:kevinwrightleft,项目名称:mozu-dotnet,代码行数:5,代码来源:HttpHelper.cs

示例6: GetHeaderValues

        internal static IEnumerable<string> GetHeaderValues(HttpRequestHeaders headers, string headerName)
        {
            var list = new List<string>();
            var values = headers.GetValues(headerName);
            if (values != null)
            {
                list.AddRange(values.Select(value => value.TrimStart(new char[0])));
            }

            return list;
        }
开发者ID:wadewegner,项目名称:TechEd_NZAU,代码行数:11,代码来源:CredentialExtensions.cs

示例7: TakeHeaderData

        private AuthorizationComponents TakeHeaderData(HttpRequestHeaders headers)
        {
            string key = "", hash = "", dateTimeSent = "";
            if (headers.Contains("Key"))
                key = headers.GetValues("key").First();
            else
            {
                throw new NoKeyProvidedException();
            }
            if (headers.Contains("Hash"))
                hash = headers.GetValues("hash").First();
            else
            {
                throw new NoHashProvidedEception();
            }
            if (headers.Contains("DateSent"))
                dateTimeSent = headers.GetValues("DateSent").First();
            else
            {
                throw new NoDateProvidedException();
            }

            if (String.IsNullOrWhiteSpace(key))
            {
                throw new InvalidHeaderException("key");
            }
            if(String.IsNullOrWhiteSpace(hash))
            {
                throw new InvalidHeaderException("hash");
            }
            if(String.IsNullOrWhiteSpace(dateTimeSent))
            {
                throw new InvalidHeaderException("date");
            }
            DateTime sent = DateTime.Parse(dateTimeSent, this.EndUserDateFormat, DateTimeStyles.AssumeUniversal);
            return new AuthorizationComponents { PublicKey = key, DataHash = hash, TimeRequestExecuted = sent };
        }
开发者ID:bruinbrown,项目名称:HMACAuth,代码行数:37,代码来源:HMACAuthAttribute.cs


注:本文中的System.Net.Http.Headers.HttpRequestHeaders.GetValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。