From 426d83c5352e259a5e66b47b26b911b6e53cf996 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 23 Apr 2020 22:30:40 +0100 Subject: [PATCH] change SimpleStreamHandler to have a processor method argument --- .../HttpServer/Interfaces/IHttpServer.cs | 2 ++ .../HttpServer/Interfaces/IStreamHandler.cs | 2 ++ .../Servers/HttpServer/SimpleStreamHandler.cs | 31 +++++++++++++------ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs index 7e80e12904..29dcf1a4c0 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs @@ -97,6 +97,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// /// void AddStreamHandler(IRequestHandler handler); + void AddSimpleStreamHandler(ISimpleStreamHandler handler); bool AddXmlRPCHandler(string method, XmlRpcMethod handler); bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive); @@ -141,6 +142,7 @@ namespace OpenSim.Framework.Servers.HttpServer bool RemoveLLSDHandler(string path, LLSDMethod handler); void RemoveStreamHandler(string httpMethod, string path); + void RemoveSimpleStreamHandler(string path); void RemoveXmlRPCHandler(string method); diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs index 75b5a79013..e72995018f 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs @@ -101,4 +101,6 @@ namespace OpenSim.Framework.Servers.HttpServer // Handle request stream, return byte array void Handle(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); } + + public delegate void SimpleStreamMethod(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); } \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/SimpleStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/SimpleStreamHandler.cs index 5b5a6de8c2..c64eba5f40 100644 --- a/OpenSim/Framework/Servers/HttpServer/SimpleStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/SimpleStreamHandler.cs @@ -38,28 +38,39 @@ namespace OpenSim.Framework.Servers.HttpServer /// /// Inheriting classes should override ProcessRequest() rather than Handle() /// - public abstract class SimpleStreamHandler : SimpleBaseRequestHandler, ISimpleStreamHandler + public class SimpleStreamHandler : SimpleBaseRequestHandler, ISimpleStreamHandler { protected IServiceAuth m_Auth; + protected SimpleStreamMethod m_processRequest; - protected SimpleStreamHandler(string path) : this(path, null, null) { } + public SimpleStreamHandler(string path) : base(path, null, null) { } + public SimpleStreamHandler(string path, string name, string description) : base(path, name, description) { } - protected SimpleStreamHandler(string path, string name, string description) - : base(path, name, description) { } + public SimpleStreamHandler(string path, SimpleStreamMethod processRequest) : base(path, null, null) + { + m_processRequest = processRequest; + } - protected SimpleStreamHandler(string path, IServiceAuth auth) + public SimpleStreamHandler(string path, IServiceAuth auth) : base(path, null, null) + { + m_Auth = auth; + } + + public SimpleStreamHandler(string path, IServiceAuth auth, SimpleStreamMethod processRequest) : base(path, null, null) { m_Auth = auth; + m_processRequest = processRequest; } - protected SimpleStreamHandler(string path, IServiceAuth auth, string name, string description) + public SimpleStreamHandler(string path, IServiceAuth auth, SimpleStreamMethod processRequest, string name, string description) : base(path, name, description) { m_Auth = auth; + m_processRequest = processRequest; } - public virtual void Handle(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + public virtual void Handle(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { RequestsReceived++; @@ -73,8 +84,10 @@ namespace OpenSim.Framework.Servers.HttpServer return; } } - - ProcessRequest(httpRequest, httpResponse); + if(m_processRequest != null) + m_processRequest(httpRequest, httpResponse); + else + ProcessRequest(httpRequest, httpResponse); RequestsHandled++; }