private static void SetAllowCredentials(MonoRailRestConfigSection configSection, NameValueCollection allowSettings) { bool allowCredentials; if (!string.IsNullOrEmpty(configSection.AllowCredentials.Allow) && bool.TryParse(configSection.AllowCredentials.Allow, out allowCredentials)) { allowSettings["Credentials"] = configSection.AllowCredentials.Allow; } }
private static void SetAllowOrigin(IRequest request, MonoRailRestConfigSection configSection, NameValueCollection allowSettings) { foreach (AllowOriginElement allowOrigin in configSection.AllowOriginList) { if (string.Compare(allowOrigin.Domain, request.Headers["Origin"], true) == 0) { allowSettings["Origin"] = allowOrigin.Domain; break; } } }
private static void SetAllowHeaders(IRequest request, MonoRailRestConfigSection configSection, NameValueCollection allowSettings) { var count = 0; foreach (AllowHeaderElement allowHeader in configSection.AllowHeaderList) { var accessControlHeaderString = request.Headers.Get("Access-Control-Request-Headers"); if (!string.IsNullOrEmpty(accessControlHeaderString)) { allowSettings["Header"] += allowHeader.Name; if (count < configSection.AllowHeaderList.Count - 1) { allowSettings["Header"] += ", "; } count++; } } }