private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) { string capUrl; if (url == "localhost") { capUrl = "/CAPS/" + UUID.Random(); IRequestHandler reqHandler = new RestStreamHandler( "POST", capUrl, m_webFetchHandler.FetchInventoryDescendentsRequest, "FetchInventoryDescendents2", agentID.ToString()); caps.RegisterHandler(capName, reqHandler); } else { capUrl = url; caps.RegisterHandler(capName, capUrl); } // m_log.DebugFormat( // "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}", // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); }
public void OnRegisterCaps(UUID agentID, Caps caps) { // m_log.DebugFormat( // "[MOAP]: Registering ObjectMedia and ObjectMediaNavigate capabilities for agent {0}", agentID); string omCapUrl = "/CAPS/" + UUID.Random(); lock (m_omCapUsers) { m_omCapUsers[omCapUrl] = agentID; m_omCapUrls[agentID] = omCapUrl; // Even though we're registering for POST we're going to get GETS and UPDATES too IRequestHandler handler = new RestStreamHandler("POST", omCapUrl, HandleObjectMediaMessage); caps.RegisterHandler("ObjectMedia", handler); } string omuCapUrl = "/CAPS/" + UUID.Random(); lock (m_omuCapUsers) { m_omuCapUsers[omuCapUrl] = agentID; m_omuCapUrls[agentID] = omuCapUrl; // Even though we're registering for POST we're going to get GETS and UPDATES too IRequestHandler handler = new RestStreamHandler("POST", omuCapUrl, HandleObjectMediaNavigateMessage); caps.RegisterHandler("ObjectMediaNavigate", handler); } }
public void RegisterRegionServiceHandlers(string capsBase) { try { // the root of all evil m_HostCapsObj.RegisterHandler( "SEED", new RestStreamHandler("POST", capsBase + m_requestPath, SeedCapRequest, "SEED", null)); m_log.DebugFormat( "[CAPS]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_HostCapsObj.AgentID); //m_capsHandlers["MapLayer"] = // new LLSDStreamhandler<OSDMapRequest, OSDMapLayerResponse>("POST", // capsBase + m_mapLayerPath, // GetMapLayer); IRequestHandler req = new RestStreamHandler( "POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory, "UpdateScript", null); m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); } catch (Exception e) { m_log.Error("[CAPS]: " + e.ToString()); } }
private void OnRegisterCaps(OpenMetaverse.UUID agentID, OpenSim.Framework.Capabilities.Caps caps) { string capsBase = "/CAPS/" + caps.CapsObjectPath; IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", (request, path, param, httpRequest, httpResponse) => RenderMaterialsPostCap(request, agentID), "RenderMaterials", null); caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, (at least at the time this was originally written), so we first set up a POST // handler normally and then add a GET handler via MainServer IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", (request, path, param, httpRequest, httpResponse) => RenderMaterialsGetCap(request), "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", (request, path, param, httpRequest, httpResponse) => RenderMaterialsPostCap(request, agentID), "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); }
private void OnRegisterCaps(UUID agentID, OpenSim.Framework.Communications.Capabilities.Caps caps) { string renderCap = CapsUtil.CreateCAPS("RenderMaterials", String.Empty); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, so we first set up a POST handler normally and then add a GET/PUT handler via MainServer IRequestHandler renderMaterialsPostHandler = new RestStreamHandler( "POST", renderCap, (request, path, param, httpRequest, httpResponse) => RenderMaterialsPostCap(request, agentID), "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsPostHandler); caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", renderCap, (request, path, param, httpRequest, httpResponse) => RenderMaterialsGetCap(request), "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", renderCap, (request, path, param, httpRequest, httpResponse) => RenderMaterialsPostCap(request, agentID), "RenderMaterials", null); MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); }
public void RegisterInventoryServiceHandlers(string capsBase) { try { // I don't think this one works... m_HostCapsObj.RegisterHandler( "NewFileAgentInventory", new LLSDStreamhandler <LLSDAssetUploadRequest, LLSDAssetUploadResponse>( "POST", capsBase + m_newInventory, NewAgentInventoryRequest, "NewFileAgentInventory", null)); IRequestHandler req = new RestStreamHandler( "POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory, "Update*", null); m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); m_HostCapsObj.RegisterHandler( "CopyInventoryFromNotecard", new RestStreamHandler( "POST", capsBase + m_copyFromNotecardPath, CopyInventoryFromNotecard, "CopyInventoryFromNotecard", null)); // As of RC 1.22.9 of the Linden client this is // supported //m_capsHandlers["WebFetchInventoryDescendents"] =new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryDescendentsRequest); // justincc: I've disabled the CAPS service for now to fix problems with selecting textures, and // subsequent inventory breakage, in the edit object pane (such as mantis 1085). This requires // enhancements (probably filling out the folder part of the LLSD reply) to our CAPS service, // but when I went on the Linden grid, the // simulators I visited (version 1.21) were, surprisingly, no longer supplying this capability. Instead, // the 1.19.1.4 client appeared to be happily flowing inventory data over UDP // // This is very probably just a temporary measure - once the CAPS service appears again on the Linden grid // we will be // able to get the data we need to implement the necessary part of the protocol to fix the issue above. // m_capsHandlers["FetchInventoryDescendents"] = // new RestStreamHandler("POST", capsBase + m_fetchInventoryPath, FetchInventoryRequest); // m_capsHandlers["FetchInventoryDescendents"] = // new LLSDStreamhandler<LLSDFetchInventoryDescendents, LLSDInventoryDescendents>("POST", // capsBase + m_fetchInventory, // FetchInventory)); // m_capsHandlers["RequestTextureDownload"] = new RestStreamHandler("POST", // capsBase + m_requestTexture, // RequestTexture); } catch (Exception e) { m_log.Error("[CAPS]: " + e.ToString()); } }
public void RegisterCaps(UUID agentID, Caps caps) { SeedCapsHandler handler = new SeedCapsHandler(m_scene, agentID, caps); IRequestHandler reqHandler = new RestStreamHandler("POST", caps.CapsBase + m_requestPath, handler.SeedCapRequest); caps.RegisterHandler("SEED", reqHandler); m_log.DebugFormat("[CAPS]: Registered seed capability {0} for {1}", caps.CapsBase + m_requestPath, agentID); }
public void RegisterCaps(UUID agentID, Caps caps) { IRequestHandler SendUserReportHandler = new RestStreamHandler( "POST", "/CAPS/" + UUID.Random(), (v, w, x, y, z) => SendUserReport(v, w, x, y, z, caps), "SendUserReportHandler", null); caps.RegisterHandler("SendUserReport", SendUserReportHandler); IRequestHandler SendUserReportWithScreenshotHandler = new RestStreamHandler( "POST", "/CAPS/" + UUID.Random(), (v, w, x, y, z) => SendUserReportWithScreenshot(v, w, x, y, z, caps), "SendUserReportWithScreenshot", null); caps.RegisterHandler("SendUserReportWithScreenshot", SendUserReportWithScreenshotHandler); }
public void RegisterCaps(UUID agentID, Caps caps) { if (m_Url == "localhost") { IRequestHandler LSLSyntaxHandler = new RestStreamHandler( "GET", "/CAPS/" + UUID.Random(), LSLSyntax, "LSLSyntax", null); caps.RegisterHandler("LSLSyntax", LSLSyntaxHandler); } else { caps.RegisterHandler("LSLSyntax", m_Url + m_SyntaxID); } }
public void RegisterInventoryServiceHandlers(string capsBase) { try { // I don't think this one works... m_capsHandlers["NewFileAgentInventory"] = new LLSDStreamhandler <LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", capsBase + m_newInventory, NewAgentInventoryRequest); m_capsHandlers["UpdateNotecardAgentInventory"] = new RestStreamHandler("POST", capsBase + m_notecardUpdatePath, NoteCardAgentInventory); m_capsHandlers["UpdateScriptAgentInventory"] = m_capsHandlers["UpdateNotecardAgentInventory"]; m_capsHandlers["UpdateScriptAgent"] = m_capsHandlers["UpdateScriptAgentInventory"]; } catch (Exception e) { m_log.Error("[Caps]: " + e.ToString()); } }
public void RegisterCaps(UUID agentID, Caps caps) { string homeLocationCap = CapsUtil.CreateCAPS("HomeLocation", String.Empty); // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET // and POST handlers, so we first set up a POST handler normally and then add a GET/PUT handler via MainServer IRequestHandler homeLocationRequestHandler = new RestStreamHandler( "POST", homeLocationCap, (request, path, param, httpRequest, httpResponse) => HomeLocation(request, agentID), "HomeLocation", null); MainServer.Instance.AddStreamHandler(homeLocationRequestHandler); caps.RegisterHandler("HomeLocation", homeLocationRequestHandler); }
public FetchInvDescServerConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { if (configName != String.Empty) { m_ConfigName = configName; } IConfig serverConfig = config.Configs[m_ConfigName]; if (serverConfig == null) { throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); } string invService = serverConfig.GetString("InventoryService", String.Empty); if (invService == String.Empty) { throw new Exception("No InventoryService in config file"); } Object[] args = new Object[] { config }; m_InventoryService = ServerUtils.LoadPlugin <IInventoryService>(invService, args); if (m_InventoryService == null) { throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName)); } string libService = serverConfig.GetString("LibraryService", String.Empty); m_LibraryService = ServerUtils.LoadPlugin <ILibraryService>(libService, args); FetchInvDescHandler webFetchHandler = new FetchInvDescHandler(m_InventoryService, m_LibraryService, null); IRequestHandler reqHandler = new RestStreamHandler( "POST", "/CAPS/WebFetchInvDesc/" /*+ UUID.Random()*/, webFetchHandler.FetchInventoryDescendentsRequest, "FetchInvDescendents", null); server.AddStreamHandler(reqHandler); }
public void RegisterRegionServiceHandlers(string capsBase) { try { // the root of all evil m_capsHandlers["SEED"] = new RestStreamHandler("POST", capsBase + m_requestPath, CapsRequest); m_log.DebugFormat("[Caps]: Registered seed capability {0} for {1}", capsBase + m_requestPath, m_agentID); m_capsHandlers["UpdateScriptTaskInventory"] = new RestStreamHandler("POST", capsBase + m_notecardTaskUpdatePath, ScriptTaskInventory); m_capsHandlers["UpdateScriptTask"] = m_capsHandlers["UpdateScriptTaskInventory"]; m_capsHandlers["UploadBakedTexture"] = new RestStreamHandler("POST", capsBase + m_uploadBakedTexturePath, UploadBakedTexture); } catch (Exception e) { m_log.Error("[Caps]: " + e.ToString()); } }
/// <summary> /// Add a REST stream handler to the underlying HTTP server. /// </summary> /// <param name="httpMethod">GET/PUT/POST/DELETE or /// similar</param> /// <param name="path">URL prefix</param> /// <param name="method">RestMethod handler doing the actual work</param> public virtual void AddRestStreamHandler(string httpMethod, string path, RestMethod method) { if (!IsEnabled) { return; } if (!path.StartsWith(_prefix)) { path = String.Format("{0}{1}", _prefix, path); } RestStreamHandler h = new RestStreamHandler(httpMethod, path, method); _httpd.AddStreamHandler(h); _handlers.Add(h); m_log.DebugFormat("{0} Added REST handler {1} {2}", MsgID, httpMethod, path); }
/// <summary> /// If there is a stream handler registered that can handle the /// request, then fine. If the request is not matched, do /// nothing. /// Note: The selection is case-insensitive /// </summary> private bool FindStreamHandler(OSHttpRequest request, OSHttpResponse response) { RequestData rdata = new RequestData(request, response, String.Empty); string bestMatch = String.Empty; string path = String.Format("{0}:{1}", rdata.method, rdata.path).ToLower(); Rest.Log.DebugFormat("{0} Checking for stream handler for <{1}>", MsgId, path); if (!IsEnabled) { return(false); } foreach (string pattern in streamHandlers.Keys) { if (path.StartsWith(pattern)) { if (pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } // Handle using the best match available if (bestMatch.Length > 0) { Rest.Log.DebugFormat("{0} Stream-based handler matched with <{1}>", MsgId, bestMatch); RestStreamHandler handler = streamHandlers[bestMatch]; rdata.buffer = handler.Handle(rdata.path, rdata.request.InputStream, rdata.request, rdata.response); rdata.AddHeader(rdata.response.ContentType, handler.ContentType); rdata.Respond("FindStreamHandler Completion"); } return(rdata.handled); }
public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName) : base(config, server, configName) { if (configName != String.Empty) { m_ConfigName = configName; } IConfig serverConfig = config.Configs[m_ConfigName]; if (serverConfig == null) { throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); } string invService = serverConfig.GetString("InventoryService", String.Empty); if (invService == String.Empty) { throw new Exception("No InventoryService in config file"); } Object[] args = new Object[] { config }; m_InventoryService = ServerUtils.LoadPlugin <IInventoryService>(invService, args); if (m_InventoryService == null) { throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName)); } FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService, UUID.Zero); IRequestHandler reqHandler = new RestStreamHandler( "POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest, "FetchInventory", null); server.AddStreamHandler(reqHandler); }
/// <summary> /// Register the Caps for inventory /// </summary> /// <param name="agentID"></param> /// <param name="server"></param> private OSDMap EventManagerOnRegisterCaps(UUID agentID, IHttpServer server) { OSDMap retVal = new OSDMap(); retVal["UpdateScriptTaskInventory"] = CapsUtil.CreateCAPS("UpdateScriptTaskInventory", ""); retVal["UpdateScriptTask"] = retVal["UpdateScriptTaskInventory"]; //Region Server bound #if (!ISWIN) IRequestHandler handler = new RestStreamHandler("POST", retVal["UpdateScriptTask"], delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return ScriptTaskInventory(agentID, request, path, param, httpRequest, httpResponse); }); #else IRequestHandler handler = new RestStreamHandler("POST", retVal["UpdateScriptTask"], (request, path, param, httpRequest, httpResponse) => ScriptTaskInventory(agentID, request, path, param, httpRequest, httpResponse)); #endif server.AddStreamHandler(handler); retVal["UpdateScriptAgentInventory"] = CapsUtil.CreateCAPS("UpdateScriptAgentInventory", ""); retVal["UpdateNotecardAgentInventory"] = retVal["UpdateScriptAgentInventory"]; retVal["UpdateScriptAgent"] = retVal["UpdateNotecardAgentInventory"]; //Unless the script engine goes, region server bound #if (!ISWIN) handler = new RestStreamHandler("POST", retVal["UpdateNotecardAgentInventory"], delegate(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { return NoteCardAgentInventory(agentID, request, path, param, httpRequest, httpResponse); }); #else handler = new RestStreamHandler("POST", retVal["UpdateNotecardAgentInventory"], (request, path, param, httpRequest, httpResponse) => NoteCardAgentInventory(agentID, request, path, param, httpRequest, httpResponse)); #endif server.AddStreamHandler(handler); return retVal; }
public void RegisterCaps(UUID agentID, Caps caps) { UUID capID = UUID.Random(); try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); string addCapURL = externalBaseURL + ADD_CAPS_TOKEN_URL + m_apToken + "/" + capID.ToString(); WebRequest req = WebRequest.Create(addCapURL); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { throw new Exception("Got response '" + response.StatusDescription + "' while trying to register CAPS with HTT"); } //register this cap url with the server caps.RegisterHandler("GetTexture", externalURL, () => this.PauseAperture(caps, capID), () => this.ResumeAperture(caps, capID), (int bwMax) => this.SetApertureBandwidth(caps, capID, bwMax)); } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } IRequestHandler requestHandler; ISimulatorFeaturesModule SimulatorFeatures = m_Scene.RequestModuleInterface <ISimulatorFeaturesModule>(); if ((SimulatorFeatures != null) && (SimulatorFeatures.MeshEnabled == true)) { //use the same cap ID for mesh and HTT. That way the token bucket in aperture will balance the //available bandwidth between mesh and http textures //capID = UUID.Random(); bool getMeshCapRegistered = false; try { if (m_useAperture == true) { string externalBaseURL = GetApertureBaseURL(caps); string externalURL = GetApertureHttUrl(caps, capID); //register this cap url with the server caps.RegisterHandler("GetMesh", externalURL); //caps control for the texture server will apply to pause mesh as well getMeshCapRegistered = true; } } catch (Exception e) { m_log.ErrorFormat( "[APERTURE] Could not contact the aperture texture server to register caps on region {0}. Server returned error {1}", caps.RegionName, e.Message); } if (getMeshCapRegistered == false) { // m_log.DebugFormat("[GETMESH]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); GetMeshHandler gmeshHandler = new GetMeshHandler(m_Scene, agentID, caps); requestHandler = new RestHTTPHandler( "GET", "/CAPS/" + UUID.Random(), httpMethod => gmeshHandler.ProcessGetMesh(httpMethod, UUID.Zero, null)); caps.RegisterHandler("GetMesh", requestHandler); } } // Upload Baked Texture UploadBakedTextureHandler uploadHandler = new UploadBakedTextureHandler(m_Scene, caps); requestHandler = new RestStreamHandler("POST", "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, uploadHandler.UploadBakedTexture); caps.RegisterHandler("UploadBakedTexture", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectCostHandler); caps.RegisterHandler("GetObjectCost", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), ResourceCostsSelected); caps.RegisterHandler("ResourceCostSelected", requestHandler); requestHandler = new RestStreamHandler("POST", caps.CapsBase + "/" + UUID.Random(), GetObjectPhysicsDataHandler); caps.RegisterHandler("GetObjectPhysicsData", requestHandler); }