aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDr Scofield2008-07-07 09:47:36 +0000
committerDr Scofield2008-07-07 09:47:36 +0000
commit7f0bcc5aa1f7afc0d24734978bfd784ae8ac1558 (patch)
tree1ead06aa0a5c7c7329b17d32509cff086126d99a
parentAddresses more problem box cut angles (diff)
downloadopensim-SC_OLD-7f0bcc5aa1f7afc0d24734978bfd784ae8ac1558.zip
opensim-SC_OLD-7f0bcc5aa1f7afc0d24734978bfd784ae8ac1558.tar.gz
opensim-SC_OLD-7f0bcc5aa1f7afc0d24734978bfd784ae8ac1558.tar.bz2
opensim-SC_OLD-7f0bcc5aa1f7afc0d24734978bfd784ae8ac1558.tar.xz
further progress on HttpServer integration: OSHttpRequest can now be
instantiated from both .NET and HttpServer code path.
-rw-r--r--OpenSim/Framework/Servers/OSHttpRequest.cs64
-rw-r--r--OpenSim/Framework/Servers/OSHttpRequestPump.cs5
-rw-r--r--OpenSim/Framework/Servers/OSHttpResponse.cs4
-rw-r--r--OpenSim/Framework/Servers/OSHttpServer.cs18
4 files changed, 65 insertions, 26 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpRequest.cs b/OpenSim/Framework/Servers/OSHttpRequest.cs
index 1eb094e..f8f542b 100644
--- a/OpenSim/Framework/Servers/OSHttpRequest.cs
+++ b/OpenSim/Framework/Servers/OSHttpRequest.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Collections.Specialized; 30using System.Collections.Specialized;
30using System.Net; 31using System.Net;
31using System.IO; 32using System.IO;
@@ -43,12 +44,12 @@ namespace OpenSim.Framework.Servers
43 private Encoding _contentEncoding; 44 private Encoding _contentEncoding;
44 private long _contentLength64; 45 private long _contentLength64;
45 private string _contentType; 46 private string _contentType;
46 private CookieCollection _cookies; 47 // private CookieCollection _cookies;
47 private NameValueCollection _headers; 48 private NameValueCollection _headers;
48 private string _httpMethod; 49 private string _httpMethod;
49 private Stream _inputStream; 50 private Stream _inputStream;
50 private bool _isSecureConnection; 51 // private bool _isSecureConnection;
51 private bool _isAuthenticated; 52 // private bool _isAuthenticated;
52 private bool _keepAlive; 53 private bool _keepAlive;
53 private bool _hasbody; 54 private bool _hasbody;
54 private string _rawUrl; 55 private string _rawUrl;
@@ -76,7 +77,7 @@ namespace OpenSim.Framework.Servers
76 77
77 public long ContentLength64 78 public long ContentLength64
78 { 79 {
79 get { return _contentLength64; } 80 get { return ContentLength; }
80 } 81 }
81 82
82 public string ContentType 83 public string ContentType
@@ -84,10 +85,11 @@ namespace OpenSim.Framework.Servers
84 get { return _contentType; } 85 get { return _contentType; }
85 } 86 }
86 87
87 public CookieCollection Cookies 88
88 { 89 // public CookieCollection Cookies
89 get { return _cookies; } 90 // {
90 } 91 // get { return _cookies; }
92 // }
91 93
92 public NameValueCollection Headers 94 public NameValueCollection Headers
93 { 95 {
@@ -104,15 +106,15 @@ namespace OpenSim.Framework.Servers
104 get { return _inputStream; } 106 get { return _inputStream; }
105 } 107 }
106 108
107 public bool IsSecureConnection 109 // public bool IsSecureConnection
108 { 110 // {
109 get { return _isSecureConnection; } 111 // get { return _isSecureConnection; }
110 } 112 // }
111 113
112 public bool IsAuthenticated 114 // public bool IsAuthenticated
113 { 115 // {
114 get { return _isAuthenticated; } 116 // get { return _isAuthenticated; }
115 } 117 // }
116 118
117 public bool HasEntityBody 119 public bool HasEntityBody
118 { 120 {
@@ -159,13 +161,13 @@ namespace OpenSim.Framework.Servers
159 _contentEncoding = req.ContentEncoding; 161 _contentEncoding = req.ContentEncoding;
160 _contentLength64 = req.ContentLength64; 162 _contentLength64 = req.ContentLength64;
161 _contentType = req.ContentType; 163 _contentType = req.ContentType;
162 _cookies = req.Cookies; 164 // _cookies = req.Cookies;
163 _headers = req.Headers; 165 _headers = req.Headers;
164 _httpMethod = req.HttpMethod; 166 _httpMethod = req.HttpMethod;
165 _hasbody = req.HasEntityBody; 167 _hasbody = req.HasEntityBody;
166 _inputStream = req.InputStream; 168 _inputStream = req.InputStream;
167 _isSecureConnection = req.IsSecureConnection; 169 // _isSecureConnection = req.IsSecureConnection;
168 _isAuthenticated = req.IsAuthenticated; 170 // _isAuthenticated = req.IsAuthenticated;
169 _keepAlive = req.KeepAlive; 171 _keepAlive = req.KeepAlive;
170 _rawUrl = req.RawUrl; 172 _rawUrl = req.RawUrl;
171 _url = req.Url; 173 _url = req.Url;
@@ -177,6 +179,30 @@ namespace OpenSim.Framework.Servers
177 { 179 {
178 // _context = context; 180 // _context = context;
179 _request = req; 181 _request = req;
182
183 _acceptTypes = req.AcceptTypes;
184 if (null != req.Headers["content-encoding"])
185 _contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]);
186 _contentLength64 = req.ContentLength;
187 if (null != req.Headers["content-type"])
188 _contentType = _request.Headers["content-type"];
189 // _cookies = req.Cookies;
190 _headers = req.Headers;
191 _httpMethod = req.Method;
192 _hasbody = req.ContentLength != 0;
193 _inputStream = req.Body;
194 // _isSecureConnection = req.IsSecureConnection;
195 // _isAuthenticated = req.IsAuthenticated;
196 _keepAlive = ConnectionType.KeepAlive == req.Connection;
197 _rawUrl = req.Uri.AbsolutePath;
198 _url = req.Uri;
199 if (null != req.Headers["user-agent"])
200 _userAgent = req.Headers["user-agent"];
201 _queryString = new NameValueCollection();
202 foreach (KeyValuePair<string, HttpInputItem> q in req.QueryString)
203 {
204 _queryString.Add(q.Key, q.Value.Value);
205 }
180 } 206 }
181 } 207 }
182} 208}
diff --git a/OpenSim/Framework/Servers/OSHttpRequestPump.cs b/OpenSim/Framework/Servers/OSHttpRequestPump.cs
index 78bd1e1..b76fadc 100644
--- a/OpenSim/Framework/Servers/OSHttpRequestPump.cs
+++ b/OpenSim/Framework/Servers/OSHttpRequestPump.cs
@@ -133,9 +133,8 @@ namespace OpenSim.Framework.Servers
133 throw new Exception(String.Format("[{0}] got unexpected OSHttpHandlerResult {1}", EngineID, rc)); 133 throw new Exception(String.Format("[{0}] got unexpected OSHttpHandlerResult {1}", EngineID, rc));
134 } 134 }
135 135
136 // Handled: clean up 136 // Handled: clean up now
137 // response.KeepAlive = false; 137 req.HttpRequest.AddHeader("keep-alive", "false");
138 // response.SendChunked = false;
139 138
140 break; 139 break;
141 } 140 }
diff --git a/OpenSim/Framework/Servers/OSHttpResponse.cs b/OpenSim/Framework/Servers/OSHttpResponse.cs
index 72be790..e1ab005 100644
--- a/OpenSim/Framework/Servers/OSHttpResponse.cs
+++ b/OpenSim/Framework/Servers/OSHttpResponse.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Framework.Servers
73 } 73 }
74 74
75 public WebHeaderCollection Headers; 75 public WebHeaderCollection Headers;
76 public CookieCollection Cookies; 76 // public CookieCollection Cookies;
77 77
78 private bool _keepAlive; 78 private bool _keepAlive;
79 public bool KeepAlive 79 public bool KeepAlive
@@ -144,7 +144,7 @@ namespace OpenSim.Framework.Servers
144 ContentLength64 = resp.ContentLength64; 144 ContentLength64 = resp.ContentLength64;
145 _contentType = resp.ContentType; 145 _contentType = resp.ContentType;
146 Headers = resp.Headers; 146 Headers = resp.Headers;
147 Cookies = resp.Cookies; 147 // Cookies = resp.Cookies;
148 KeepAlive = resp.KeepAlive; 148 KeepAlive = resp.KeepAlive;
149 OutputStream = resp.OutputStream; 149 OutputStream = resp.OutputStream;
150 RedirectLocation = resp.RedirectLocation; 150 RedirectLocation = resp.RedirectLocation;
diff --git a/OpenSim/Framework/Servers/OSHttpServer.cs b/OpenSim/Framework/Servers/OSHttpServer.cs
index aade003..4940101 100644
--- a/OpenSim/Framework/Servers/OSHttpServer.cs
+++ b/OpenSim/Framework/Servers/OSHttpServer.cs
@@ -50,6 +50,8 @@ namespace OpenSim.Framework.Servers
50 { 50 {
51 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private object _syncObject = new object();
54
53 // underlying HttpServer.HttpListener 55 // underlying HttpServer.HttpListener
54 protected HttpListener _listener; 56 protected HttpListener _listener;
55 // underlying core/engine thread 57 // underlying core/engine thread
@@ -157,16 +159,28 @@ namespace OpenSim.Framework.Servers
157 _pumps[i].Start(); 159 _pumps[i].Start();
158 } 160 }
159 161
162 public void Stop()
163 {
164 lock (_syncObject) Monitor.Pulse(_syncObject);
165 }
166
160 /// <summary> 167 /// <summary>
161 /// Engine keeps the HTTP server running. 168 /// Engine keeps the HTTP server running.
162 /// </summary> 169 /// </summary>
163 private void Engine() 170 private void Engine()
164 { 171 {
165 while (true) 172 try {
166 {
167 _listener.RequestHandler += OnHttpRequest; 173 _listener.RequestHandler += OnHttpRequest;
168 _listener.Start(QueueSize); 174 _listener.Start(QueueSize);
175 _log.InfoFormat("[{0}] HTTP server started", EngineID);
176
177 lock (_syncObject) Monitor.Wait(_syncObject);
178 }
179 catch (Exception)
180 {
169 } 181 }
182
183 _log.InfoFormat("[{0}] HTTP server terminated", EngineID);
170 } 184 }
171 185
172 186