From 9f5f65c8477e3d05f384bafbb1bdf6dcb3f577c8 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 9 Jul 2007 23:32:29 +0000 Subject: * LLSDStreamhandler now works. --- OpenSim/Framework/Servers/BaseStreamHandler.cs | 2 +- OpenSim/Framework/Servers/RestStreamHandler.cs | 2 +- OpenSim/Region/Capabilities/Caps.cs | 20 ++++++++++---------- OpenSim/Region/Capabilities/LLSDStreamHandler.cs | 14 ++++++++------ 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/BaseStreamHandler.cs b/OpenSim/Framework/Servers/BaseStreamHandler.cs index 5fcf678..0d9c674 100644 --- a/OpenSim/Framework/Servers/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/BaseStreamHandler.cs @@ -31,7 +31,7 @@ namespace OpenSim.Framework.Servers public abstract byte[] Handle(string path, Stream request); - protected BaseStreamHandler(string path, string httpMethod ) + protected BaseStreamHandler(string httpMethod, string path) { m_httpMethod = httpMethod; m_path = path; diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs index 7ca369d..1b3b41c 100644 --- a/OpenSim/Framework/Servers/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/RestStreamHandler.cs @@ -23,7 +23,7 @@ namespace OpenSim.Framework.Servers return Encoding.UTF8.GetBytes(responseString); } - public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( path, httpMethod ) + public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) { m_restMethod = restMethod; } diff --git a/OpenSim/Region/Capabilities/Caps.cs b/OpenSim/Region/Capabilities/Caps.cs index fdc21cf..6068076 100644 --- a/OpenSim/Region/Capabilities/Caps.cs +++ b/OpenSim/Region/Capabilities/Caps.cs @@ -74,10 +74,10 @@ namespace OpenSim.Region.Capabilities string capsBase = "/CAPS/" + m_capsObjectPath; - AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); + //AddLegacyCapsHandler( httpListener, m_mapLayerPath, MapLayer); - //httpListener.AddStreamHandler( - // new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); + httpListener.AddStreamHandler( + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, this.GetMapLayer )); AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest); AddLegacyCapsHandler(httpListener, m_newInventory, NewAgentInventory); @@ -86,13 +86,6 @@ namespace OpenSim.Region.Capabilities } - public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) - { - LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); - mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); - return mapResponse; - } - [Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { @@ -151,6 +144,13 @@ namespace OpenSim.Region.Capabilities return res; } + public LLSDMapLayerResponse GetMapLayer(LLSDMapRequest mapReq) + { + LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); + mapResponse.LayerData.Array.Add(this.BuildLLSDMapLayerResponse()); + return mapResponse; + } + /// /// diff --git a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs index ff63353..7d99b6e 100644 --- a/OpenSim/Region/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Region/Capabilities/LLSDStreamHandler.cs @@ -14,25 +14,27 @@ namespace OpenSim.Region.Capabilities private LLSDMethod m_method; public LLSDStreamhandler(string httpMethod, string path, LLSDMethod method) - : base(httpMethod, path) + : base(httpMethod, path ) { m_method = method; } public override byte[] Handle(string path, Stream request) { - Encoding encoding = Encoding.UTF8; - StreamReader streamReader = new StreamReader(request, encoding); + //Encoding encoding = Encoding.UTF8; + //StreamReader streamReader = new StreamReader(request, false); - string requestBody = streamReader.ReadToEnd(); - streamReader.Close(); + //string requestBody = streamReader.ReadToEnd(); + //streamReader.Close(); - Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(encoding.GetBytes(requestBody)); + Hashtable hash = (Hashtable)LLSD.LLSDDeserialize( request ); TRequest llsdRequest = new TRequest(); LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest); TResponse response = m_method(llsdRequest); + Encoding encoding = new UTF8Encoding(false); + return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) ); } -- cgit v1.1