further progress on HttpServer integration: OSHttpRequest can now be
instantiated from both .NET and HttpServer code path.0.6.0-stable
parent
56c6bdcb26
commit
7f0bcc5aa1
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -43,12 +44,12 @@ namespace OpenSim.Framework.Servers
|
||||||
private Encoding _contentEncoding;
|
private Encoding _contentEncoding;
|
||||||
private long _contentLength64;
|
private long _contentLength64;
|
||||||
private string _contentType;
|
private string _contentType;
|
||||||
private CookieCollection _cookies;
|
// private CookieCollection _cookies;
|
||||||
private NameValueCollection _headers;
|
private NameValueCollection _headers;
|
||||||
private string _httpMethod;
|
private string _httpMethod;
|
||||||
private Stream _inputStream;
|
private Stream _inputStream;
|
||||||
private bool _isSecureConnection;
|
// private bool _isSecureConnection;
|
||||||
private bool _isAuthenticated;
|
// private bool _isAuthenticated;
|
||||||
private bool _keepAlive;
|
private bool _keepAlive;
|
||||||
private bool _hasbody;
|
private bool _hasbody;
|
||||||
private string _rawUrl;
|
private string _rawUrl;
|
||||||
|
@ -76,7 +77,7 @@ namespace OpenSim.Framework.Servers
|
||||||
|
|
||||||
public long ContentLength64
|
public long ContentLength64
|
||||||
{
|
{
|
||||||
get { return _contentLength64; }
|
get { return ContentLength; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ContentType
|
public string ContentType
|
||||||
|
@ -84,10 +85,11 @@ namespace OpenSim.Framework.Servers
|
||||||
get { return _contentType; }
|
get { return _contentType; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public CookieCollection Cookies
|
|
||||||
{
|
// public CookieCollection Cookies
|
||||||
get { return _cookies; }
|
// {
|
||||||
}
|
// get { return _cookies; }
|
||||||
|
// }
|
||||||
|
|
||||||
public NameValueCollection Headers
|
public NameValueCollection Headers
|
||||||
{
|
{
|
||||||
|
@ -104,15 +106,15 @@ namespace OpenSim.Framework.Servers
|
||||||
get { return _inputStream; }
|
get { return _inputStream; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsSecureConnection
|
// public bool IsSecureConnection
|
||||||
{
|
// {
|
||||||
get { return _isSecureConnection; }
|
// get { return _isSecureConnection; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool IsAuthenticated
|
// public bool IsAuthenticated
|
||||||
{
|
// {
|
||||||
get { return _isAuthenticated; }
|
// get { return _isAuthenticated; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool HasEntityBody
|
public bool HasEntityBody
|
||||||
{
|
{
|
||||||
|
@ -159,13 +161,13 @@ namespace OpenSim.Framework.Servers
|
||||||
_contentEncoding = req.ContentEncoding;
|
_contentEncoding = req.ContentEncoding;
|
||||||
_contentLength64 = req.ContentLength64;
|
_contentLength64 = req.ContentLength64;
|
||||||
_contentType = req.ContentType;
|
_contentType = req.ContentType;
|
||||||
_cookies = req.Cookies;
|
// _cookies = req.Cookies;
|
||||||
_headers = req.Headers;
|
_headers = req.Headers;
|
||||||
_httpMethod = req.HttpMethod;
|
_httpMethod = req.HttpMethod;
|
||||||
_hasbody = req.HasEntityBody;
|
_hasbody = req.HasEntityBody;
|
||||||
_inputStream = req.InputStream;
|
_inputStream = req.InputStream;
|
||||||
_isSecureConnection = req.IsSecureConnection;
|
// _isSecureConnection = req.IsSecureConnection;
|
||||||
_isAuthenticated = req.IsAuthenticated;
|
// _isAuthenticated = req.IsAuthenticated;
|
||||||
_keepAlive = req.KeepAlive;
|
_keepAlive = req.KeepAlive;
|
||||||
_rawUrl = req.RawUrl;
|
_rawUrl = req.RawUrl;
|
||||||
_url = req.Url;
|
_url = req.Url;
|
||||||
|
@ -177,6 +179,30 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
// _context = context;
|
// _context = context;
|
||||||
_request = req;
|
_request = req;
|
||||||
|
|
||||||
|
_acceptTypes = req.AcceptTypes;
|
||||||
|
if (null != req.Headers["content-encoding"])
|
||||||
|
_contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]);
|
||||||
|
_contentLength64 = req.ContentLength;
|
||||||
|
if (null != req.Headers["content-type"])
|
||||||
|
_contentType = _request.Headers["content-type"];
|
||||||
|
// _cookies = req.Cookies;
|
||||||
|
_headers = req.Headers;
|
||||||
|
_httpMethod = req.Method;
|
||||||
|
_hasbody = req.ContentLength != 0;
|
||||||
|
_inputStream = req.Body;
|
||||||
|
// _isSecureConnection = req.IsSecureConnection;
|
||||||
|
// _isAuthenticated = req.IsAuthenticated;
|
||||||
|
_keepAlive = ConnectionType.KeepAlive == req.Connection;
|
||||||
|
_rawUrl = req.Uri.AbsolutePath;
|
||||||
|
_url = req.Uri;
|
||||||
|
if (null != req.Headers["user-agent"])
|
||||||
|
_userAgent = req.Headers["user-agent"];
|
||||||
|
_queryString = new NameValueCollection();
|
||||||
|
foreach (KeyValuePair<string, HttpInputItem> q in req.QueryString)
|
||||||
|
{
|
||||||
|
_queryString.Add(q.Key, q.Value.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,9 +133,8 @@ namespace OpenSim.Framework.Servers
|
||||||
throw new Exception(String.Format("[{0}] got unexpected OSHttpHandlerResult {1}", EngineID, rc));
|
throw new Exception(String.Format("[{0}] got unexpected OSHttpHandlerResult {1}", EngineID, rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handled: clean up
|
// Handled: clean up now
|
||||||
// response.KeepAlive = false;
|
req.HttpRequest.AddHeader("keep-alive", "false");
|
||||||
// response.SendChunked = false;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace OpenSim.Framework.Servers
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebHeaderCollection Headers;
|
public WebHeaderCollection Headers;
|
||||||
public CookieCollection Cookies;
|
// public CookieCollection Cookies;
|
||||||
|
|
||||||
private bool _keepAlive;
|
private bool _keepAlive;
|
||||||
public bool KeepAlive
|
public bool KeepAlive
|
||||||
|
@ -144,7 +144,7 @@ namespace OpenSim.Framework.Servers
|
||||||
ContentLength64 = resp.ContentLength64;
|
ContentLength64 = resp.ContentLength64;
|
||||||
_contentType = resp.ContentType;
|
_contentType = resp.ContentType;
|
||||||
Headers = resp.Headers;
|
Headers = resp.Headers;
|
||||||
Cookies = resp.Cookies;
|
// Cookies = resp.Cookies;
|
||||||
KeepAlive = resp.KeepAlive;
|
KeepAlive = resp.KeepAlive;
|
||||||
OutputStream = resp.OutputStream;
|
OutputStream = resp.OutputStream;
|
||||||
RedirectLocation = resp.RedirectLocation;
|
RedirectLocation = resp.RedirectLocation;
|
||||||
|
|
|
@ -50,6 +50,8 @@ namespace OpenSim.Framework.Servers
|
||||||
{
|
{
|
||||||
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
private object _syncObject = new object();
|
||||||
|
|
||||||
// underlying HttpServer.HttpListener
|
// underlying HttpServer.HttpListener
|
||||||
protected HttpListener _listener;
|
protected HttpListener _listener;
|
||||||
// underlying core/engine thread
|
// underlying core/engine thread
|
||||||
|
@ -157,16 +159,28 @@ namespace OpenSim.Framework.Servers
|
||||||
_pumps[i].Start();
|
_pumps[i].Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
lock (_syncObject) Monitor.Pulse(_syncObject);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Engine keeps the HTTP server running.
|
/// Engine keeps the HTTP server running.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Engine()
|
private void Engine()
|
||||||
{
|
{
|
||||||
while (true)
|
try {
|
||||||
{
|
|
||||||
_listener.RequestHandler += OnHttpRequest;
|
_listener.RequestHandler += OnHttpRequest;
|
||||||
_listener.Start(QueueSize);
|
_listener.Start(QueueSize);
|
||||||
|
_log.InfoFormat("[{0}] HTTP server started", EngineID);
|
||||||
|
|
||||||
|
lock (_syncObject) Monitor.Wait(_syncObject);
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
_log.InfoFormat("[{0}] HTTP server terminated", EngineID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue