/// <summary> /// Validates the headers/cookies passed in for the request /// </summary> /// <param name="requestHeaders"></param> /// <param name="failedReason"></param> /// <returns></returns> public static bool ValidateHeaders(HttpRequestHeaders requestHeaders, out string failedReason) { var cookieToken = requestHeaders.GetCookieValue(CsrfValidationCookieName); return(ValidateHeaders( requestHeaders.ToDictionary(x => x.Key, x => x.Value).ToArray(), cookieToken == null ? null : cookieToken, out failedReason)); }
private void Logging(HttpRequestHeaders headers, string content) { if (_log == null) { return; } _log.WriteLine("Request Header: " + string.Join(", ", headers.ToDictionary(x => x.Key, x => x.Value.FirstOrDefault()))); _log.WriteLine("Request Content: " + content); }
/// <summary> /// Validates the headers/cookies passed in for the request /// </summary> /// <param name="requestHeaders"></param> /// <param name="failedReason"></param> /// <returns></returns> public static bool ValidateHeaders(HttpRequestHeaders requestHeaders, out string failedReason) { var cookieToken = requestHeaders .GetCookies() .Select(c => c[CsrfValidationCookieName]) .FirstOrDefault(); return(ValidateHeaders( requestHeaders.ToDictionary(x => x.Key, x => x.Value).ToArray(), cookieToken == null ? null : cookieToken.Value, out failedReason)); }
private Dictionary <string, string> ParseHeaders(HttpRequestHeaders RequestHeaders) { Dictionary <string, string> rh = RequestHeaders.ToDictionary(a => a.Key, a => string.Join(";", a.Value)); return(rh); }