aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/BaseHttpServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Servers/BaseHttpServer.cs')
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs34
1 files changed, 26 insertions, 8 deletions
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 52d2a2c..a4a7b2b 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Framework.Servers
43 protected Thread m_workerThread; 43 protected Thread m_workerThread;
44 protected HttpListener m_httpListener; 44 protected HttpListener m_httpListener;
45 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 45 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
46 protected Dictionary<string, IStreamHandler> m_streamHandlers = new Dictionary<string, IStreamHandler>(); 46 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
47 protected int m_port; 47 protected int m_port;
48 protected bool m_firstcaps = true; 48 protected bool m_firstcaps = true;
49 49
@@ -57,7 +57,7 @@ namespace OpenSim.Framework.Servers
57 m_port = port; 57 m_port = port;
58 } 58 }
59 59
60 public void AddStreamHandler(IStreamHandler handler) 60 public void AddStreamHandler(IRequestHandler handler)
61 { 61 {
62 string httpMethod = handler.HttpMethod; 62 string httpMethod = handler.HttpMethod;
63 string path = handler.Path; 63 string path = handler.Path;
@@ -97,14 +97,32 @@ namespace OpenSim.Framework.Servers
97 string path = request.RawUrl; 97 string path = request.RawUrl;
98 string handlerKey = GetHandlerKey(request.HttpMethod, path); 98 string handlerKey = GetHandlerKey(request.HttpMethod, path);
99 99
100 IStreamHandler streamHandler; 100 IRequestHandler requestHandler;
101 101
102 if (TryGetStreamHandler(handlerKey, out streamHandler)) 102 if (TryGetStreamHandler(handlerKey, out requestHandler))
103 { 103 {
104 byte[] buffer = streamHandler.Handle(path, request.InputStream); 104 // Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
105 request.InputStream.Close(); 105 byte[] buffer;
106 if (requestHandler is IStreamedRequestHandler)
107 {
108 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
109 buffer = streamedRequestHandler.Handle(path, request.InputStream);
110
111 }
112 else
113 {
114 IStreamHandler streamHandler = (IStreamHandler)requestHandler;
106 115
107 response.ContentType = streamHandler.ContentType; 116 using (MemoryStream memoryStream = new MemoryStream())
117 {
118 streamHandler.Handle(path, request.InputStream, memoryStream);
119 memoryStream.Flush();
120 buffer = memoryStream.ToArray();
121 }
122 }
123
124 request.InputStream.Close();
125 response.ContentType = requestHandler.ContentType;
108 response.ContentLength64 = buffer.LongLength; 126 response.ContentLength64 = buffer.LongLength;
109 response.OutputStream.Write(buffer, 0, buffer.Length); 127 response.OutputStream.Write(buffer, 0, buffer.Length);
110 response.OutputStream.Close(); 128 response.OutputStream.Close();
@@ -115,7 +133,7 @@ namespace OpenSim.Framework.Servers
115 } 133 }
116 } 134 }
117 135
118 private bool TryGetStreamHandler(string handlerKey, out IStreamHandler streamHandler) 136 private bool TryGetStreamHandler(string handlerKey, out IRequestHandler streamHandler)
119 { 137 {
120 string bestMatch = null; 138 string bestMatch = null;
121 139