private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) { string bestMatch = null; lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { if (handlerKey.StartsWith(pattern)) { if (string.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } if (string.IsNullOrEmpty(bestMatch)) { HTTPHandler = null; return(false); } else { HTTPHandler = m_HTTPHandlers[bestMatch]; return(true); } } }
public void RegisterCaps(IRegionClientCapsService service) { m_service = service; m_agentInfoService = service.Registry.RequestModuleInterface <IAgentInfoService>(); GenericHTTPMethod method = delegate(Hashtable httpMethod) { return(ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID)); }; service.AddStreamHandler("UpdateAgentLanguage", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentLanguage", ""), method)); method = delegate(Hashtable httpMethod) { return(ProcessUpdateAgentInfo(httpMethod, m_service.AgentID)); }; service.AddStreamHandler("UpdateAgentInformation", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentInformation", ""), method)); method = delegate(Hashtable httpMethod) { return(HomeLocation(httpMethod, m_service.AgentID)); }; service.AddStreamHandler("HomeLocation", new RestHTTPHandler("POST", service.CreateCAPS("HomeLocation", ""), method)); }
/// <summary> /// Instantiate an HTTP handler. /// </summary> /// <param name="handler">a GenericHTTPMethod</param> /// <param name="method">null or HTTP method regex</param> /// <param name="path">null or path regex</param> /// <param name="query">null or dictionary with query regexs</param> /// <param name="headers">null or dictionary with header /// regexs</param> /// <param name="whitelist">null or IP address whitelist</param> public OSHttpHttpHandler(GenericHTTPMethod handler, Regex method, Regex path, Dictionary <string, Regex> query, Dictionary <string, Regex> headers, Regex whitelist) : base(method, path, query, headers, new Regex(@"^text/html", RegexOptions.IgnoreCase | RegexOptions.Compiled), whitelist) { _handler = handler; }
public GenericHTTPDOSProtector(GenericHTTPMethod normalMethod, GenericHTTPMethod throttledMethod, BasicDosProtectorOptions options) { _normalMethod = normalMethod; _throttledMethod = throttledMethod; _options = options; _dosProtector = new BasicDOSProtector(_options); }
/// <summary> /// Instantiate an HTTP handler. /// </summary> /// <param name="handler">a GenericHTTPMethod</param> /// <param name="method">null or HTTP method regex</param> /// <param name="path">null or path regex</param> /// <param name="query">null or dictionary with query regexs</param> /// <param name="headers">null or dictionary with header /// regexs</param> /// <param name="whitelist">null or IP address whitelist</param> public OSHttpHttpHandler(GenericHTTPMethod handler, Regex method, Regex path, Dictionary<string, Regex> query, Dictionary<string, Regex> headers, Regex whitelist) : base(method, path, query, headers, new Regex(@"^text/html", RegexOptions.IgnoreCase | RegexOptions.Compiled), whitelist) { _handler = handler; }
public void RegisterCaps(IRegionClientCapsService service) { m_service = service; m_agentInfoService = service.Registry.RequestModuleInterface <IAgentInfoService>(); m_agentProcessing = service.Registry.RequestModuleInterface <IAgentProcessing>(); #if (!ISWIN) GenericHTTPMethod method = delegate(Hashtable httpMethod) { return(ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID)); }; #else GenericHTTPMethod method = httpMethod => ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID); #endif service.AddStreamHandler("UpdateAgentLanguage", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentLanguage", ""), method)); #if (!ISWIN) method = delegate(Hashtable httpMethod) { return(ProcessUpdateAgentInfo(httpMethod, m_service.AgentID)); }; #else method = httpMethod => ProcessUpdateAgentInfo(httpMethod, m_service.AgentID); #endif service.AddStreamHandler("UpdateAgentInformation", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentInformation", ""), method)); service.AddStreamHandler("AvatarPickerSearch", new StreamHandler("GET", service.CreateCAPS("AvatarPickerSearch", ""), ProcessAvatarPickerSearch)); #if (!ISWIN) method = delegate(Hashtable httpMethod) { return(HomeLocation(httpMethod, m_service.AgentID)); }; #else method = httpMethod => HomeLocation(httpMethod, m_service.AgentID); #endif service.AddStreamHandler("HomeLocation", new RestHTTPHandler("POST", service.CreateCAPS("HomeLocation", ""), method)); #if (!ISWIN) method = delegate(Hashtable httpMethod) { return(TeleportLocation(httpMethod, m_service.AgentID)); }; #else method = httpMethod => TeleportLocation(httpMethod, m_service.AgentID); #endif service.AddStreamHandler("TeleportLocation", new RestHTTPHandler("POST", service.CreateCAPS("TeleportLocation", ""), method)); }
public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) { lock (m_HTTPHandlers) { if (!m_HTTPHandlers.ContainsKey(methodName)) { m_HTTPHandlers.Add(methodName, handler); return(true); } } return(false); }
private bool TryGetHTTPHandlerPathBased(string path, out GenericHTTPMethod httpHandler) { string[] pathbase = path.Split('/'); string searchquery = "/"; httpHandler = null; if (pathbase.Length < 1) { return(false); } for (int i = 1; i < pathbase.Length; i++) { searchquery += pathbase[i]; if (pathbase.Length - 1 != i) { searchquery += "/"; } } string bestMatch = null; lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { if (searchquery.ToLowerInvariant().StartsWith(pattern.ToLowerInvariant())) { if (string.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) { if (pattern == "/" && searchquery == "/" || pattern != "/") { bestMatch = pattern; } } } } if (string.IsNullOrEmpty(bestMatch)) { httpHandler = null; return(false); } else { if (bestMatch == "/" && searchquery != "/") { return(false); } httpHandler = m_HTTPHandlers[bestMatch]; return(true); } } }
public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) { //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); lock (m_HTTPHandlers) { if (!m_HTTPHandlers.ContainsKey(methodName)) { m_HTTPHandlers.Add(methodName, handler); return true; } } //must already have a handler for that path so return false return false; }
public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) { bool pollHandlerResult = false; lock (m_pollHandlers) { if (!m_pollHandlers.ContainsKey(methodName)) { m_pollHandlers.Add(methodName,args); pollHandlerResult = true; } } if (pollHandlerResult) return AddHTTPHandler(methodName, handler); return false; }
public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod) : base(httpMethod, path) { m_dhttpMethod = dhttpMethod; }
private bool TryGetHTTPHandlerPathBased(string path, out GenericHTTPMethod httpHandler) { httpHandler = null; // Pull out the first part of the path // splitting the path by '/' means we'll get the following return.. // {0}/{1}/{2} // where {0} isn't something we really control 100% string[] pathbase = path.Split('/'); string searchquery = "/"; if (pathbase.Length < 1) return false; for (int i = 1; i < pathbase.Length; i++) { searchquery += pathbase[i]; if (pathbase.Length - 1 != i) searchquery += "/"; } // while the matching algorithm below doesn't require it, we're expecting a query in the form // // [] = optional // /resource/UUID/action[/action] // // now try to get the closest match to the reigstered path // at least for OGP, registered path would probably only consist of the /resource/ string bestMatch = null; // m_log.DebugFormat( // "[BASE HTTP HANDLER]: TryGetHTTPHandlerPathBased() looking for HTTP handler to match {0}", searchquery); lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { if (searchquery.ToLower().StartsWith(pattern.ToLower())) { if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) { // You have to specifically register for '/' and to get it, you must specifically request it if (pattern == "/" && searchquery == "/" || pattern != "/") bestMatch = pattern; } } } if (String.IsNullOrEmpty(bestMatch)) { httpHandler = null; return false; } else { if (bestMatch == "/" && searchquery != "/") return false; httpHandler = m_HTTPHandlers[bestMatch]; return true; } } }
/// <summary> /// Instantiate an HTTP handler. /// </summary> /// <param name="handler">a GenericHTTPMethod</param> public OSHttpHttpHandler(GenericHTTPMethod handler) : this(handler, new Regex(@"^GET$", RegexOptions.IgnoreCase | RegexOptions.Compiled), null, null, null, null) { }
public RestHTTPHandler( string httpMethod, string path, GenericHTTPMethod dhttpMethod, string name, string description) : base(httpMethod, path, name, description) { m_dhttpMethod = dhttpMethod; }
public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) { //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); try { m_HTTPHandlers.AddIfNotExists(methodName, delegate() { return handler; }); return true; } catch(ThreadedClasses.RwLockedDictionary<string, GenericHTTPMethod>.KeyAlreadyExistsException) { } //must already have a handler for that path so return false return false; }
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) { // m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); string bestMatch = null; m_HTTPHandlers.ForEach(delegate(string pattern) { if ((handlerKey == pattern) || (handlerKey.StartsWith(pattern) && (HANDLER_SEPARATORS.IndexOf(handlerKey[pattern.Length]) >= 0))) { if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) { bestMatch = pattern; } } }); if (String.IsNullOrEmpty(bestMatch)) { HTTPHandler = null; return false; } else { HTTPHandler = m_HTTPHandlers[bestMatch]; return true; } }
private bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) { // m_log.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); string bestMatch = null; lock (m_HTTPHandlers) { foreach (string pattern in m_HTTPHandlers.Keys) { if (handlerKey.StartsWith(pattern)) { if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } if (String.IsNullOrEmpty(bestMatch)) { HTTPHandler = null; return false; } else { HTTPHandler = m_HTTPHandlers[bestMatch]; return true; } } }
internal bool TryGetHTTPHandler(string handlerKey, out GenericHTTPMethod HTTPHandler) { // MainConsole.Instance.DebugFormat("[BASE HTTP HANDLER]: Looking for HTTP handler for {0}", handlerKey); string bestMatch = null; lock (m_HTTPHandlers) { if (m_HTTPHandlers.TryGetValue(handlerKey, out HTTPHandler)) return true; foreach (string pattern in m_HTTPHandlers.Keys) { if (handlerKey.StartsWith(pattern)) { if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } if (String.IsNullOrEmpty(bestMatch)) { HTTPHandler = null; return false; } HTTPHandler = m_HTTPHandlers[bestMatch]; return true; } }