aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs19
1 files changed, 18 insertions, 1 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
index 252cc2a..f160734 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
@@ -26,6 +26,8 @@
26 */ 26 */
27 27
28using System.IO; 28using System.IO;
29using System.Net;
30using OpenSim.Framework.ServiceAuth;
29 31
30namespace OpenSim.Framework.Servers.HttpServer 32namespace OpenSim.Framework.Servers.HttpServer
31{ 33{
@@ -37,15 +39,30 @@ namespace OpenSim.Framework.Servers.HttpServer
37 /// </remarks> 39 /// </remarks>
38 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler 40 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler
39 { 41 {
40 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} 42 protected IServiceAuth m_Auth;
43
44 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { }
41 45
42 protected BaseStreamHandler(string httpMethod, string path, string name, string description) 46 protected BaseStreamHandler(string httpMethod, string path, string name, string description)
43 : base(httpMethod, path, name, description) {} 47 : base(httpMethod, path, name, description) {}
44 48
49 protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth)
50 : base(httpMethod, path, null, null)
51 {
52 m_Auth = auth;
53 }
54
45 public virtual byte[] Handle( 55 public virtual byte[] Handle(
46 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 56 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
47 { 57 {
48 RequestsReceived++; 58 RequestsReceived++;
59 if (m_Auth != null && !m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader))
60 {
61
62 httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
63 httpResponse.ContentType = "text/plain";
64 return new byte[0];
65 }
49 66
50 byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); 67 byte[] result = ProcessRequest(path, request, httpRequest, httpResponse);
51 68