this is a snapshot of the OSHttpServer work-in-progress. it's an initial skeleton,
far from complete, just want to check in early and often.0.6.0-stable
parent
22c7845e0c
commit
d7ec686691
|
@ -44,7 +44,9 @@ namespace OpenSim.Framework.Servers
|
|||
private string _httpMethod;
|
||||
private Stream _inputStream;
|
||||
private bool _isSecureConnection;
|
||||
private bool _isAuthenticated;
|
||||
private bool _keepAlive;
|
||||
private bool _hasbody;
|
||||
private string _rawUrl;
|
||||
private Uri _url;
|
||||
private NameValueCollection _queryString;
|
||||
|
@ -95,6 +97,16 @@ namespace OpenSim.Framework.Servers
|
|||
get { return _isSecureConnection; }
|
||||
}
|
||||
|
||||
public bool IsAuthenticated
|
||||
{
|
||||
get { return _isAuthenticated; }
|
||||
}
|
||||
|
||||
public bool HasEntityBody
|
||||
{
|
||||
get { return _hasbody; }
|
||||
}
|
||||
|
||||
public bool KeepAlive
|
||||
{
|
||||
get { return _keepAlive; }
|
||||
|
@ -133,8 +145,10 @@ namespace OpenSim.Framework.Servers
|
|||
_cookies = req.Cookies;
|
||||
_headers = req.Headers;
|
||||
_httpMethod = req.HttpMethod;
|
||||
_hasbody = req.HasEntityBody;
|
||||
_inputStream = req.InputStream;
|
||||
_isSecureConnection = req.IsSecureConnection;
|
||||
_isAuthenticated = req.IsAuthenticated;
|
||||
_keepAlive = req.KeepAlive;
|
||||
_rawUrl = req.RawUrl;
|
||||
_url = req.Url;
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using HttpServer;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
/// <summary>
|
||||
/// OSHttpServer provides an HTTP server bound to a specific
|
||||
/// port. When instantiated with just address and port it uses
|
||||
/// normal HTTP, when instantiated with address, port, and X509
|
||||
/// certificate, it uses HTTPS.
|
||||
/// </summary>
|
||||
public class OSHttpRequestPump
|
||||
{
|
||||
protected OSHttpServer _httpServer;
|
||||
|
||||
public OSHttpRequestPump()
|
||||
{
|
||||
}
|
||||
|
||||
public static OSHttpRequestPump[] Pumps(OSHttpServer server, int poolSize)
|
||||
{
|
||||
OSHttpRequestPump[] pumps = new OSHttpRequestPump[poolSize];
|
||||
for(int i = 0; i < pumps.Length; i++)
|
||||
{
|
||||
pumps[i]._httpServer = server;
|
||||
}
|
||||
|
||||
return pumps;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using log4net;
|
||||
using HttpServer;
|
||||
|
||||
using HttpListener = HttpServer.HttpListener;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
/// <summary>
|
||||
/// OSHttpServer provides an HTTP server bound to a specific
|
||||
/// port. When instantiated with just address and port it uses
|
||||
/// normal HTTP, when instantiated with address, port, and X509
|
||||
/// certificate, it uses HTTPS.
|
||||
/// </summary>
|
||||
public class OSHttpServer
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// underlying HttpServer.HttpListener
|
||||
protected HttpListener _listener;
|
||||
protected Thread _engine;
|
||||
|
||||
// OSHttpRequestPumps "pumping" incoming OSHttpRequests
|
||||
// upwards
|
||||
protected OSHttpRequestPump[] _pumps;
|
||||
|
||||
// thread identifier
|
||||
protected string _engineId;
|
||||
public string EngineID
|
||||
{
|
||||
get { return _engineId; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if this is an HTTPS connection; false otherwise.
|
||||
/// </summary>
|
||||
protected bool _isSecure;
|
||||
public bool IsSecure
|
||||
{
|
||||
get { return _isSecure; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate an HTTP server.
|
||||
/// </summary>
|
||||
public OSHttpServer(IPAddress address, int port, int poolSize)
|
||||
{
|
||||
_engineId = String.Format("OSHttpServer [HTTP:{0}/ps:{1}]", port, poolSize);
|
||||
_isSecure = false;
|
||||
|
||||
_pumps = OSHttpRequestPump.Pumps(this, poolSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Instantiate an HTTPS server.
|
||||
/// </summary>
|
||||
public OSHttpServer(IPAddress address, int port, X509Certificate certificate, int poolSize) :
|
||||
this(address, port, poolSize)
|
||||
{
|
||||
_engineId = String.Format("OSHttpServer [HTTPS:{0}/ps:{1}]", port, poolSize);
|
||||
_isSecure = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start the HTTP server engine.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
_engine = new Thread(new ThreadStart(Engine));
|
||||
_engine.Name = _engineId;
|
||||
_engine.IsBackground = true;
|
||||
_engine.Start();
|
||||
ThreadTracker.Add(_engine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
private void Engine()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// do stuff
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
38
prebuild.xml
38
prebuild.xml
|
@ -457,6 +457,7 @@
|
|||
<Reference name="libsecondlife.dll"/>
|
||||
<Reference name="XMLRPC.dll"/>
|
||||
<Reference name="log4net"/>
|
||||
<Reference name="HttpServer"/>
|
||||
|
||||
<Files>
|
||||
<Match pattern="*.cs" recurse="true"/>
|
||||
|
@ -1125,6 +1126,7 @@
|
|||
<Match pattern="*.cs" recurse="false"/>
|
||||
</Files>
|
||||
</Project>
|
||||
|
||||
<Project name="OpenSim.ApplicationPlugins.Rest.Regions"
|
||||
path="OpenSim/ApplicationPlugins/Rest/Regions" type="Library">
|
||||
<Configuration name="Debug">
|
||||
|
@ -1163,42 +1165,6 @@
|
|||
</Project>
|
||||
<!-- /REST plugins -->
|
||||
|
||||
|
||||
|
||||
<Project name="OpenSim.ApplicationPlugins.RemoteInventoryController" path="OpenSim/ApplicationPlugins/RemoteInventoryController" type="Library">
|
||||
<Configuration name="Debug">
|
||||
<Options>
|
||||
<OutputPath>../../../bin/</OutputPath>
|
||||
</Options>
|
||||
</Configuration>
|
||||
<Configuration name="Release">
|
||||
<Options>
|
||||
<OutputPath>../../../bin/</OutputPath>
|
||||
</Options>
|
||||
</Configuration>
|
||||
|
||||
<ReferencePath>../../../bin/</ReferencePath>
|
||||
<Reference name="Mono.Addins.dll" />
|
||||
<Reference name="System"/>
|
||||
<Reference name="System.Xml"/>
|
||||
<Reference name="libsecondlife.dll" />
|
||||
<Reference name="Nini.dll" />
|
||||
<Reference name="XMLRPC.dll" />
|
||||
<Reference name="OpenSim"/>
|
||||
<Reference name="OpenSim.Region.ClientStack"/>
|
||||
<Reference name="OpenSim.Region.Environment"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Servers"/>
|
||||
<Reference name="OpenSim.Framework.Console"/>
|
||||
<Reference name="OpenSim.Framework.Communications"/>
|
||||
<Reference name="OpenSim.Framework.Communications.Cache"/>
|
||||
<Reference name="log4net"/>
|
||||
|
||||
<Files>
|
||||
<Match pattern="*.cs" recurse="true"/>
|
||||
</Files>
|
||||
</Project>
|
||||
|
||||
<!-- Scene Server API Example Apps -->
|
||||
|
||||
<Project name="OpenSim.Region.DataSnapshot" path="OpenSim/Region/DataSnapshot" type="Library">
|
||||
|
|
Loading…
Reference in New Issue