public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; Request = pRequest; RequestTime = System.Environment.TickCount; RequestID = UUID.Random(); }
public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; HttpContext = pHttpContext; Request = pRequest; RequestTime = System.Environment.TickCount; }
public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; HttpContext = pHttpContext; Request = pRequest; RequestTime = Environment.TickCount; RequestID = UUID.Random(); }
public PollServiceHttpRequest( PollServiceEventArgs pPollServiceArgs, HttpServerLib.HttpClientContext pHttpContext, HttpServerLib.HttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; HttpContext = pHttpContext; Request = pRequest; RequestTime = System.Environment.TickCount; RequestID = UUID.Random(); }
/* * private void GenContextHash() * { * * Random rnd = new Random(); * contextHash = 0; * if (Request.Headers["remote_addr"] != null) * contextHash = (Request.Headers["remote_addr"]).GetHashCode() << 16; * else * contextHash = rnd.Next() << 16; * if (Request.Headers["remote_port"] != null) * { * string[] strPorts = Request.Headers["remote_port"].Split(new char[] { ',' }); * contextHash += Int32.Parse(strPorts[0]); * } * else * contextHash += rnd.Next() & 0xffff; * * } */ public PollServiceHttpRequest( PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) { PollServiceArgs = pPollServiceArgs; HttpContext = pHttpContext; Request = pRequest; RequestTime = System.Environment.TickCount; RequestID = UUID.Random(); // GenContextHash(); contextHash = HttpContext.contextID; }
private bool TryGetPollServiceHTTPHandler(string handlerKey, out PollServiceEventArgs oServiceEventArgs) { string bestMatch = null; lock (m_pollHandlers) { foreach (string pattern in m_pollHandlers.Keys) { if (handlerKey.StartsWith(pattern)) { if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } if (String.IsNullOrEmpty(bestMatch)) { oServiceEventArgs = null; return false; } else { oServiceEventArgs = m_pollHandlers[bestMatch]; return true; } } }
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 bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args) { lock (m_pollHandlers) { if (!m_pollHandlers.ContainsKey(methodName)) { m_pollHandlers.Add(methodName, args); return true; } } return false; }
public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler) { return m_pollServiceHandlers.TryGetValue(name, out pollHandler); }
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) { // m_log.DebugFormat( // "[CAPS]: Registering handler with name {0}, url {1} for {2}", // capName, pollServiceHandler.Url, m_agentID, m_regionName); m_pollServiceHandlers.Add(capName, pollServiceHandler); m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler); // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; // string protocol = "http"; // string hostName = m_httpListenerHostName; // // if (MainServer.Instance.UseSSL) // { // hostName = MainServer.Instance.SSLCommonName; // port = MainServer.Instance.SSLPort; // protocol = "https"; // } // RegisterHandler( // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); }
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) { m_pollServiceHandlers.Add(capName, pollServiceHandler); m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler); // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; // string protocol = "http"; // string hostName = m_httpListenerHostName; // // if (MainServer.Instance.UseSSL) // { // hostName = MainServer.Instance.SSLCommonName; // port = MainServer.Instance.SSLPort; // protocol = "https"; // } // RegisterHandler( // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); }
public UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); if (m_HttpsServer == null) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } lock (m_UrlMap) /* this lock here is for preventing concurrency when checking for Url amount */ { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.requests = new ThreadedClasses.RwLockedDictionary<UUID, RequestData>(); m_UrlMap[url] = urlData; string uri = "/lslhttps/" + urlcode.ToString() + "/"; PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(uri, args); m_log.DebugFormat( "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } return urlcode; }
public UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID, Hashtable options) { UUID urlcode = UUID.Random(); if (m_HttpsServer == null) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } lock (m_UrlMap) { if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; urlData.itemID = itemID; urlData.engine = engine; urlData.url = url; urlData.urlcode = urlcode; urlData.isSsl = true; urlData.requests = new Dictionary<UUID, RequestData>(); urlData.allowXss = false; if (options != null && options["allowXss"] != null) urlData.allowXss = true; m_UrlMap[url] = urlData; string uri = "/lslhttps/" + urlcode.ToString() + "/"; PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, uri, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; m_HttpsServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( // "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", // uri, itemID, host.Name, host.LocalId); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } return urlcode; }
private bool TryGetPollServiceHTTPHandler(string handlerKey, out PollServiceEventArgs oServiceEventArgs) { string bestMatch = null; m_pollHandlers.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)) { oServiceEventArgs = null; return false; } else { oServiceEventArgs = m_pollHandlers[bestMatch]; return true; } }
public bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args) { try { m_pollHandlers.AddIfNotExists(methodName, delegate() { return args; }); return true; } catch(ThreadedClasses.RwLockedDictionary<string, PollServiceEventArgs>.KeyAlreadyExistsException) { } return false; }