private void CapsHandler(HttpRequest req) { string[] splitquery = req.RawUrl.Split('?'); string[] elements = splitquery[0].Substring(1).Split('/'); if (elements.Length < 3) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } UUID sessionid; if (!UUID.TryParse(elements[2], out sessionid)) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } bool foundIP = false; UUID agent = UUID.Zero; UserSessionInfo userSession; if (m_UserSessionService.TryGetValue(sessionid, out userSession) && userSession.ClientIPAddress == req.CallerIP) { agent = userSession.User.ID; foundIP = true; } if (!foundIP || !m_UserAccountService.ContainsKey(agent)) { req.ErrorResponse(HttpStatusCode.NotFound, "Not found"); return; } string rawPrefixUrl = "/UserCAPS/InventoryAPIv3/" + sessionid; string serverURI = req.IsSsl ? m_HttpsServer.ServerURI : m_HttpServer.ServerURI; serverURI = serverURI.Substring(0, serverURI.Length - 1); AISv3Handler.MainHandler(new AISv3Handler.Request( req, m_InventoryService, new UGUI(agent), false, rawPrefixUrl, serverURI + rawPrefixUrl)); }
public void HandleInventoryAPIv3(ViewerAgent agent, AgentCircuit circuit, HttpRequest req) { string capsUrl = req.IsSsl ? m_HttpsServer.ServerURI : m_HttpServer.ServerURI; string rawPrefixUrl = req.RawUrl.Substring(0, PrefixCapsUrl.Length); capsUrl += rawPrefixUrl.Substring(1); if (req.CallerIP != circuit.RemoteIP) { req.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden"); return; } var reqcontext = new AISv3Handler.Request(req, agent.InventoryService, agent.Owner, false, rawPrefixUrl, capsUrl); AISv3Handler.MainHandler(reqcontext); }