예제 #1
0
 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;
     }
 }
예제 #2
0
 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;
         }
     }
 }
예제 #3
0
 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++;
         }
     }
 }