本文整理汇总了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;
}
示例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;
}
}
}
示例3: AuthenticateUser
public static bool AuthenticateUser(HttpRequestHeaders HttpHeaders)
{
if (HttpHeaders.Contains(HttpRequestHeaderName))
{
var authHeader = HttpHeaders.GetValues(HttpRequestHeaderName).First();
return _authenticateHeaderValue(authHeader);
}
return false;
}
示例4: ParseFirstValue
public static int? ParseFirstValue(string header, HttpRequestHeaders headers)
{
IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
return GetIntValue(value);
}
示例5: GetHeaderValue
public static string GetHeaderValue(string header, HttpRequestHeaders headers)
{
IEnumerable<string> value = (headers.Contains(header) ? headers.GetValues(header) : null);
return GetStringValue(value);
}
示例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;
}
示例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 };
}