mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
* re-fixed the utf-16 bug in xmlRpcResponse serialization
* added LLSDStreamHandler.cs to Caps (Haven't enabled it yet, though) * removed last traces of old rest handling
This commit is contained in:
40
OpenSim/Region/Capabilities/LLSDStreamHandler.cs
Normal file
40
OpenSim/Region/Capabilities/LLSDStreamHandler.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Servers;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Capabilities
|
||||
{
|
||||
public class LLSDStreamhandler<TRequest, TResponse> : BaseStreamHandler
|
||||
where TRequest : new()
|
||||
{
|
||||
private LLSDMethod<TRequest, TResponse> m_method;
|
||||
|
||||
public LLSDStreamhandler(string httpMethod, string path, LLSDMethod<TRequest, TResponse> method)
|
||||
: base(httpMethod, path)
|
||||
{
|
||||
m_method = method;
|
||||
}
|
||||
|
||||
public override byte[] Handle(string path, Stream request)
|
||||
{
|
||||
Encoding encoding = Encoding.UTF8;
|
||||
StreamReader streamReader = new StreamReader(request, encoding);
|
||||
|
||||
string requestBody = streamReader.ReadToEnd();
|
||||
streamReader.Close();
|
||||
|
||||
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(encoding.GetBytes(requestBody));
|
||||
TRequest llsdRequest = new TRequest();
|
||||
LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
|
||||
|
||||
TResponse response = m_method(llsdRequest);
|
||||
|
||||
return encoding.GetBytes( LLSDHelpers.SerialiseLLSDReply(response) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user