aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs49
1 files changed, 46 insertions, 3 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
index 6342983..41aa19b 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
@@ -26,17 +26,60 @@
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{
34 /// <summary>
35 /// Base streamed request handler.
36 /// </summary>
37 /// <remarks>
38 /// Inheriting classes should override ProcessRequest() rather than Handle()
39 /// </remarks>
32 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler 40 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler
33 { 41 {
34 public abstract byte[] Handle(string path, Stream request, 42 protected IServiceAuth m_Auth;
35 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
36 43
37 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} 44 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { }
38 45
39 protected BaseStreamHandler(string httpMethod, string path, string name, string description) 46 protected BaseStreamHandler(string httpMethod, string path, string name, string description)
40 : base(httpMethod, path, name, description) {} 47 : base(httpMethod, path, name, description) {}
48
49 protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth)
50 : base(httpMethod, path, null, null)
51 {
52 m_Auth = auth;
53 }
54
55 public virtual byte[] Handle(
56 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
57 {
58 RequestsReceived++;
59
60 if (m_Auth != null)
61 {
62 HttpStatusCode statusCode;
63
64 if (!m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader, out statusCode))
65 {
66 httpResponse.StatusCode = (int)statusCode;
67 httpResponse.ContentType = "text/plain";
68 return new byte[0];
69 }
70 }
71
72 byte[] result = ProcessRequest(path, request, httpRequest, httpResponse);
73
74 RequestsHandled++;
75
76 return result;
77 }
78
79 protected virtual byte[] ProcessRequest(
80 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
81 {
82 return null;
83 }
41 } 84 }
42} \ No newline at end of file 85} \ No newline at end of file