From 4567555c49cb560dd6f109bbfec42086af3de56f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Dec 2011 20:44:20 +0000 Subject: Implement IOSHttpRequest and IOSHttpResponse http interfaces and use instead of OSHttpRequest/OSHttpResponse. This is required for the substitution of different HTTP servers or the newer HttpServer.dll without having to commit to a particular implementation. This is also required to write regression tests that involve the HTTP layer. If you need to recompile, all you need to do is replace OSHttpRequest/OSHttpResponse references with IOSHttpRequest/IOSHttpResponse. --- .../ApplicationPlugins/Rest/Regions/GETHandler.cs | 12 +- .../Rest/Regions/GETRegionInfoHandler.cs | 4 +- .../ApplicationPlugins/Rest/Regions/POSTHandler.cs | 6 +- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 8 +- .../Handlers/GetTexture/GetTextureHandler.cs | 6 +- .../UploadBakedTextureHandler.cs | 2 +- .../WebFetchInvDescHandler.cs | 2 +- OpenSim/Capabilities/LLSDStreamHandler.cs | 2 +- OpenSim/Framework/Servers/BaseOpenSimServer.cs | 2 +- .../Servers/HttpServer/BaseStreamHandler.cs | 2 +- .../Servers/HttpServer/BinaryStreamHandler.cs | 2 +- .../HttpServer/Interfaces/IOSHttpRequest.cs | 59 +++++++++ .../HttpServer/Interfaces/IOSHttpResponse.cs | 138 +++++++++++++++++++++ .../HttpServer/Interfaces/IStreamHandler.cs | 4 +- .../Framework/Servers/HttpServer/OSHttpRequest.cs | 3 +- .../Framework/Servers/HttpServer/OSHttpResponse.cs | 5 +- .../Servers/HttpServer/RestDeserialiseHandler.cs | 2 +- OpenSim/Framework/Servers/HttpServer/RestMethod.cs | 2 +- .../Servers/HttpServer/RestSessionService.cs | 4 +- .../Servers/HttpServer/RestStreamHandler.cs | 2 +- OpenSim/Region/Application/OpenSimBase.cs | 6 +- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 6 +- .../Avatar/Friends/FriendsRequestHandler.cs | 4 +- .../CoreModules/World/Land/LandManagementModule.cs | 4 +- .../CoreModules/World/Media/Moap/MoapModule.cs | 4 +- .../CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- OpenSim/Region/DataSnapshot/DataRequestHandler.cs | 2 +- .../Region/Framework/Scenes/RegionStatsHandler.cs | 2 +- .../Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 6 +- .../World/WorldView/WorldViewRequestHandler.cs | 2 +- OpenSim/Region/UserStatistics/WebStatsModule.cs | 2 +- .../Handlers/Asset/AssetServerDeleteHandler.cs | 2 +- .../Server/Handlers/Asset/AssetServerGetHandler.cs | 2 +- .../Handlers/Asset/AssetServerPostHandler.cs | 2 +- .../AuthenticationServerPostHandler.cs | 2 +- .../Handlers/Authentication/OpenIdServerHandler.cs | 2 +- .../AuthorizationServerPostHandler.cs | 2 +- .../Handlers/Avatar/AvatarServerPostHandler.cs | 2 +- OpenSim/Server/Handlers/Base/Utils.cs | 2 +- .../Handlers/Friends/FriendsServerPostHandler.cs | 2 +- OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs | 2 +- .../Server/Handlers/Grid/GridServerPostHandler.cs | 2 +- .../Handlers/GridUser/GridUserServerPostHandler.cs | 2 +- .../Hypergrid/HGFriendsServerPostHandler.cs | 2 +- .../Handlers/Hypergrid/HeloServerConnector.cs | 8 +- .../Inventory/InventoryServerMoveItemsHandler.cs | 2 +- .../Handlers/Inventory/XInventoryInConnector.cs | 2 +- .../Server/Handlers/Map/MapAddServerConnector.cs | 2 +- .../Server/Handlers/Map/MapGetServerConnector.cs | 2 +- .../Server/Handlers/Neighbour/NeighbourHandlers.cs | 8 +- .../Handlers/Presence/PresenceServerPostHandler.cs | 2 +- .../Server/Handlers/Simulation/AgentHandlers.cs | 4 +- .../UserAccounts/UserAccountServerPostHandler.cs | 2 +- OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | 112 ++++++++++++++--- prebuild.xml | 5 +- 56 files changed, 384 insertions(+), 104 deletions(-) create mode 100644 OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs create mode 100644 OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs index dea166d..d99ba57 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs @@ -41,7 +41,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions { #region GET methods public string GetHandler(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // foreach (string h in httpRequest.Headers.AllKeys) // foreach (string v in httpRequest.Headers.GetValues(h)) @@ -64,7 +64,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions } } - public string GetHandlerRegions(OSHttpResponse httpResponse) + public string GetHandlerRegions(IOSHttpResponse httpResponse) { RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); @@ -95,7 +95,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions return rxw.ToString(); } - public string GetHandlerRegion(OSHttpResponse httpResponse, string param) + public string GetHandlerRegion(IOSHttpResponse httpResponse, string param) { // be resilient and don't get confused by a terminating '/' param = param.TrimEnd(new char[]{'/'}); @@ -180,7 +180,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions } #endregion GET methods - protected string RegionTerrain(OSHttpResponse httpResponse, Scene scene) + protected string RegionTerrain(IOSHttpResponse httpResponse, Scene scene) { httpResponse.SendChunked = true; httpResponse.ContentType = "text/xml"; @@ -190,7 +190,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions // "GET", "terrain not implemented"); } - protected string RegionStats(OSHttpResponse httpResponse, Scene scene) + protected string RegionStats(IOSHttpResponse httpResponse, Scene scene) { int users = scene.GetRootAgentCount(); int objects = scene.Entities.Count - users; @@ -213,7 +213,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions return rxw.ToString(); } - protected string RegionPrims(OSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max) + protected string RegionPrims(IOSHttpResponse httpResponse, Scene scene, Vector3 min, Vector3 max) { httpResponse.SendChunked = true; httpResponse.ContentType = "text/xml"; diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs index 279db4c..468faea 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs @@ -40,7 +40,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions { #region GET methods public string GetRegionInfoHandler(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // foreach (string h in httpRequest.Headers.AllKeys) // foreach (string v in httpRequest.Headers.GetValues(h)) @@ -64,7 +64,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions } } - public string GetRegionInfoHandlerRegions(OSHttpResponse httpResponse) + public string GetRegionInfoHandlerRegions(IOSHttpResponse httpResponse) { RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs index e0318e5..f666f45 100644 --- a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs @@ -40,7 +40,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions #region POST methods public string PostHandler(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // foreach (string h in httpRequest.Headers.AllKeys) // foreach (string v in httpRequest.Headers.GetValues(h)) @@ -92,7 +92,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions } } - public string CreateRegion(OSHttpRequest request, OSHttpResponse response) + public string CreateRegion(IOSHttpRequest request, IOSHttpResponse response) { RestXmlWriter rxw = new RestXmlWriter(new StringWriter()); @@ -108,7 +108,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions return rxw.ToString(); } - public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene) + public string LoadPrims(string requestBody, IOSHttpRequest request, IOSHttpResponse response, Scene scene) { IRegionSerialiserModule serialiser = scene.RequestModuleInterface(); if (serialiser != null) diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs index ff1502a..eb16750 100644 --- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs +++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs @@ -328,7 +328,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// /// HTTP request header /// true when the HTTP request came from god. - protected bool IsGod(OSHttpRequest request) + protected bool IsGod(IOSHttpRequest request) { string[] keys = request.Headers.GetValues("X-OpenSim-Godkey"); if (null == keys) return false; @@ -342,7 +342,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// HTTP header is indeed the password on file for the avatar /// specified by the UUID /// - protected bool IsVerifiedUser(OSHttpRequest request, UUID uuid) + protected bool IsVerifiedUser(IOSHttpRequest request, UUID uuid) { // XXX under construction return false; @@ -377,7 +377,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// failure message /// This should probably set a return code as /// well. (?) - protected string Failure(OSHttpResponse response, OSHttpStatusCode status, + protected string Failure(IOSHttpResponse response, OSHttpStatusCode status, string method, string format, params string[] msg) { string m = String.Format(format, msg); @@ -396,7 +396,7 @@ namespace OpenSim.ApplicationPlugins.Rest /// exception causing the failure message /// This should probably set a return code as /// well. (?) - public string Failure(OSHttpResponse response, OSHttpStatusCode status, + public string Failure(IOSHttpResponse response, OSHttpStatusCode status, string method, Exception e) { string m = String.Format("exception occurred: {0}", e.Message); diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 7ab30ce..ae95821 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -64,7 +64,7 @@ namespace OpenSim.Capabilities.Handlers m_assetService = assService; } - public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // Try to parse the texture ID from the request URL NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); @@ -127,7 +127,7 @@ namespace OpenSim.Capabilities.Handlers /// /// /// False for "caller try another codec"; true otherwise - private bool FetchTexture(OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format) + private bool FetchTexture(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID textureID, string format) { // m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format); AssetBase texture; @@ -211,7 +211,7 @@ namespace OpenSim.Capabilities.Handlers return true; } - private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format) + private void WriteTextureData(IOSHttpRequest request, IOSHttpResponse response, AssetBase texture, string format) { string range = request.Headers.GetOne("Range"); diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs index b89fd6a..e0ccc3c 100644 --- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs @@ -73,7 +73,7 @@ namespace OpenSim.Capabilities.Handlers /// /// The upload response if the request is successful, null otherwise. public string UploadBakedTexture( - string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { try { diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 2dade5b..a086c0e 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Capabilities.Handlers m_LibraryService = libService; } - public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // lock (m_fetchLock) // { diff --git a/OpenSim/Capabilities/LLSDStreamHandler.cs b/OpenSim/Capabilities/LLSDStreamHandler.cs index 7aaa994..c7c1fc9 100644 --- a/OpenSim/Capabilities/LLSDStreamHandler.cs +++ b/OpenSim/Capabilities/LLSDStreamHandler.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Capabilities } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { //Encoding encoding = Util.UTF8; //StreamReader streamReader = new StreamReader(request, false); diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index db063f1..4c381d0 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs @@ -600,7 +600,7 @@ namespace OpenSim.Framework.Servers } - public string StatReport(OSHttpRequest httpRequest) + public string StatReport(IOSHttpRequest httpRequest) { // If we catch a request for "callback", wrap the response in the value for jsonp if (httpRequest.Query.ContainsKey("callback")) diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 04943d1..f1cde74 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs @@ -32,7 +32,7 @@ namespace OpenSim.Framework.Servers.HttpServer public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler { public abstract byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse); + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); protected BaseStreamHandler(string httpMethod, string path) : base(httpMethod, path) { diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs index bae4e1b..1699233 100644 --- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Servers.HttpServer { private BinaryMethod m_method; - public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { byte[] data = ReadFully(request); string param = GetParam(path); diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs new file mode 100644 index 0000000..caf0edd --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs @@ -0,0 +1,59 @@ +/* + * 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 OpenSimulator 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.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Net; +using System.Text; +using System.Web; + +namespace OpenSim.Framework.Servers.HttpServer +{ + public interface IOSHttpRequest + { + string[] AcceptTypes { get; } + Encoding ContentEncoding { get; } + long ContentLength { get; } + long ContentLength64 { get; } + string ContentType { get; } + HttpCookieCollection Cookies { get; } + bool HasEntityBody { get; } + NameValueCollection Headers { get; } + string HttpMethod { get; } + Stream InputStream { get; } + bool IsSecured { get; } + bool KeepAlive { get; } + NameValueCollection QueryString { get; } + Hashtable Query { get; } + string RawUrl { get; } + IPEndPoint RemoteIPEndPoint { get; } + Uri Url { get; } + string UserAgent { get; } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs new file mode 100644 index 0000000..33a1663 --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs @@ -0,0 +1,138 @@ +/* + * 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 OpenSimulator 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.Collections; +using System.Collections.Specialized; +using System.IO; +using System.Net; +using System.Text; +using System.Web; + +namespace OpenSim.Framework.Servers.HttpServer +{ + public interface IOSHttpResponse + { + /// + /// Content type property. + /// + /// + /// Setting this property will also set IsContentTypeSet to + /// true. + /// + string ContentType { get; set; } + + /// + /// Boolean property indicating whether the content type + /// property actively has been set. + /// + /// + /// IsContentTypeSet will go away together with .NET base. + /// + // public bool IsContentTypeSet + // { + // get { return _contentTypeSet; } + // } + // private bool _contentTypeSet; + + /// + /// Length of the body content; 0 if there is no body. + /// + long ContentLength { get; set; } + + /// + /// Alias for ContentLength. + /// + long ContentLength64 { get; set; } + + /// + /// Encoding of the body content. + /// + Encoding ContentEncoding { get; set; } + + bool KeepAlive { get; set; } + + /// + /// Get or set the keep alive timeout property (default is + /// 20). Setting this to 0 also disables KeepAlive. Setting + /// this to something else but 0 also enable KeepAlive. + /// + int KeepAliveTimeout { get; set; } + + /// + /// Return the output stream feeding the body. + /// + /// + /// On its way out... + /// + Stream OutputStream { get; } + + string ProtocolVersion { get; set; } + + /// + /// Return the output stream feeding the body. + /// + Stream Body { get; } + + /// + /// Set a redirct location. + /// + string RedirectLocation { set; } + + /// + /// Chunk transfers. + /// + bool SendChunked { get; set; } + + /// + /// HTTP status code. + /// + int StatusCode { get; set; } + + /// + /// HTTP status description. + /// + string StatusDescription { get; set; } + + bool ReuseContext { get; set; } + + /// + /// Add a header field and content to the response. + /// + /// string containing the header field + /// name + /// string containing the header field + /// value + void AddHeader(string key, string value); + + /// + /// Send the response back to the remote client + /// + void Send(); + } +} + diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs index 2e1bc0b..a449c2d 100644 --- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs @@ -45,13 +45,13 @@ namespace OpenSim.Framework.Servers.HttpServer public interface IStreamedRequestHandler : IRequestHandler { // Handle request stream, return byte array - byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse); + byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); } public interface IStreamHandler : IRequestHandler { // Handle request stream, return byte array - void Handle(string path, Stream request, Stream response, OSHttpRequest httpReqbuest, OSHttpResponse httpResponse); + void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); } public interface IGenericHTTPHandler : IRequestHandler diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs index e354dfb..fc8daf3 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpRequest.cs @@ -39,7 +39,7 @@ using log4net; namespace OpenSim.Framework.Servers.HttpServer { - public class OSHttpRequest + public class OSHttpRequest : IOSHttpRequest { private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -174,7 +174,6 @@ namespace OpenSim.Framework.Servers.HttpServer } private Dictionary _whiteboard = new Dictionary(); - public OSHttpRequest() {} public OSHttpRequest(IHttpClientContext context, IHttpRequest req) diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs index 7029289..f9227ac 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpResponse.cs @@ -36,7 +36,7 @@ namespace OpenSim.Framework.Servers.HttpServer /// OSHttpResponse is the OpenSim representation of an HTTP /// response. /// - public class OSHttpResponse + public class OSHttpResponse : IOSHttpResponse { /// /// Content type property. @@ -275,7 +275,6 @@ namespace OpenSim.Framework.Servers.HttpServer } } - protected IHttpResponse _httpResponse; private IHttpClientContext _httpClientContext; @@ -331,4 +330,4 @@ namespace OpenSim.Framework.Servers.HttpServer } } -} +} \ No newline at end of file diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs index 3f2b265..a467a83 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs @@ -45,7 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer } public void Handle(string path, Stream request, Stream responseStream, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { TRequest deserial; using (XmlTextReader xmlReader = new XmlTextReader(request)) diff --git a/OpenSim/Framework/Servers/HttpServer/RestMethod.cs b/OpenSim/Framework/Servers/HttpServer/RestMethod.cs index f97efbe..80bc7ef 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestMethod.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestMethod.cs @@ -28,5 +28,5 @@ namespace OpenSim.Framework.Servers.HttpServer { public delegate string RestMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse); + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse); } diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 7ebb462..19c03a8 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs @@ -211,7 +211,7 @@ namespace OpenSim.Framework.Servers.HttpServer } public void Handle(string path, Stream request, Stream responseStream, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { RestSessionObject deserial = default(RestSessionObject); bool fail = false; @@ -270,7 +270,7 @@ namespace OpenSim.Framework.Servers.HttpServer } public void Handle(string path, Stream request, Stream responseStream, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { TRequest deserial = default(TRequest); bool fail = false; diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs index 2d43cd4..d2c4002 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs @@ -39,7 +39,7 @@ namespace OpenSim.Framework.Servers.HttpServer get { return m_restMethod; } } - public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { Encoding encoding = Encoding.UTF8; StreamReader streamReader = new StreamReader(request, encoding); diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 0a78df2..bae44ee 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -718,7 +718,7 @@ namespace OpenSim public class SimStatusHandler : IStreamedRequestHandler { public byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes("OK"); } @@ -755,7 +755,7 @@ namespace OpenSim } public byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); } @@ -796,7 +796,7 @@ namespace OpenSim } public byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 98dda36..2347cf2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -223,7 +223,7 @@ namespace OpenSim.Region.ClientStack.Linden /// HTTP response header object /// public string SeedCapRequest(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.Debug("[CAPS]: Seed Caps Request in region: " + m_regionName); @@ -256,7 +256,7 @@ namespace OpenSim.Region.ClientStack.Linden /// HTTP response header object /// public string ScriptTaskInventory(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { try { @@ -685,7 +685,7 @@ namespace OpenSim.Region.ClientStack.Linden /// /// public string NoteCardAgentInventory(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { //m_log.Debug("[CAPS]: NoteCardAgentInventory Request in region: " + m_regionName + "\n" + request); //m_log.Debug("[CAPS]: NoteCardAgentInventory Request is: " + request); diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index 1b53a42..637beef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -54,8 +54,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_FriendsModule = fmodule; } - public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle( + string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 2117827..94bba83 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1421,7 +1421,7 @@ namespace OpenSim.Region.CoreModules.World.Land caps.RegisterHandler("RemoteParcelRequest", new RestStreamHandler("POST", capsBase + remoteParcelRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return RemoteParcelRequest(request, path, param, agentID, caps); })); @@ -1429,7 +1429,7 @@ namespace OpenSim.Region.CoreModules.World.Land caps.RegisterHandler("ParcelPropertiesUpdate", new RestStreamHandler("POST", "/CAPS/" + parcelCapID, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ProcessPropertiesUpdate(request, path, param, agentID, caps); })); diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 898ca4a..5239f50 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs @@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap /// /// protected string HandleObjectMediaMessage( - string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[MOAP]: Got ObjectMedia path [{0}], raw request [{1}]", path, request); @@ -474,7 +474,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap /// /param> /// protected string HandleObjectMediaNavigateMessage( - string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[MOAP]: Got ObjectMediaNavigate request [{0}]", request); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 95c727f..9b0e2ff 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -193,7 +193,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap caps.RegisterHandler("MapLayer", new RestStreamHandler("POST", capsBase + m_mapLayerPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return MapLayerRequest(request, path, param, agentID, caps); diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs index a505999..b760454 100644 --- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs +++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.DataSnapshot } public string OnDiscoveryAttempt(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { //Very static for now, flexible enough to add new formats LLSDDiscoveryResponse llsd_response = new LLSDDiscoveryResponse(); diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index 4578236..6c5685c 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); } - public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return Util.UTF8.GetBytes(Report()); } diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index a5bba4f..5323a95 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs @@ -309,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps); @@ -317,7 +317,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps); @@ -325,7 +325,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ChatSessionRequest(scene, request, path, param, agentID, caps); diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 534bf92..70e2f7e 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -421,7 +421,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ProvisionVoiceAccountRequest", new RestStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ProvisionVoiceAccountRequest(scene, request, path, param, agentID, caps); @@ -429,7 +429,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ParcelVoiceInfoRequest", new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ParcelVoiceInfoRequest(scene, request, path, param, agentID, caps); @@ -437,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice caps.RegisterHandler("ChatSessionRequest", new RestStreamHandler("POST", capsBase + m_chatSessionRequestPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ChatSessionRequest(scene, request, path, param, agentID, caps); diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs index f47d9c7..550b5d4 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { httpResponse.ContentType = "image/jpeg"; diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index 0251ee8..fca9fd0 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs @@ -306,7 +306,7 @@ namespace OpenSim.Region.UserStatistics caps.RegisterHandler("ViewerStats", new RestStreamHandler("POST", capsPath, delegate(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return ViewerStatsReport(request, path, param, agentID, caps); diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 8014fb5..0cfe5b1 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Asset } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { bool result = false; diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs index 43c1693..8f7412b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs @@ -55,7 +55,7 @@ namespace OpenSim.Server.Handlers.Asset } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { byte[] result = new byte[0]; diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs index 1fcd3ed..87b3d2d 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs @@ -55,7 +55,7 @@ namespace OpenSim.Server.Handlers.Asset } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); AssetBase asset = (AssetBase) xs.Deserialize(request); diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 4d1b0ff..a19b599 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs @@ -71,7 +71,7 @@ namespace OpenSim.Server.Handlers.Authentication } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { string[] p = SplitParams(path); diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs index e73961b..440b898 100644 --- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs @@ -219,7 +219,7 @@ For more information, see http://openid.net/. /// Handles all GET and POST requests for OpenID identifier pages and endpoint /// server communication /// - public void Handle(string path, Stream request, Stream response, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public void Handle(string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath)); diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs index d656238..bcf9d47 100644 --- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs @@ -55,7 +55,7 @@ namespace OpenSim.Server.Handlers.Authorization } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest)); AuthorizationRequest Authorization = (AuthorizationRequest) xs.Deserialize(request); diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index 49c2e43..3ee405c 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Avatar } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Base/Utils.cs b/OpenSim/Server/Handlers/Base/Utils.cs index 92372a0..48d923f 100644 --- a/OpenSim/Server/Handlers/Base/Utils.cs +++ b/OpenSim/Server/Handlers/Base/Utils.cs @@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Base } } - public static bool GetAuthentication(OSHttpRequest httpRequest, out string authority, out string authKey) + public static bool GetAuthentication(IOSHttpRequest httpRequest, out string authority, out string authKey) { authority = string.Empty; authKey = string.Empty; diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index fc97d8c..59420f5 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs @@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Friends } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs index afe2f27..645a77f 100644 --- a/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs +++ b/OpenSim/Server/Handlers/Grid/GridInfoHandlers.cs @@ -129,7 +129,7 @@ namespace OpenSim.Server.Handlers.Grid } public string RestGetGridInfoMethod(string request, string path, string param, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StringBuilder sb = new StringBuilder(); diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index edc0561..bebf482 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs @@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Grid } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 485bc3e..4c0d52e 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.GridUser } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index 56f130e..661507e 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs @@ -61,7 +61,7 @@ namespace OpenSim.Server.Handlers.Hypergrid } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs index 4accea1..f306b1c 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs @@ -63,12 +63,12 @@ namespace OpenSim.Server.Handlers.Hypergrid } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return OKResponse(httpResponse); } - private byte[] OKResponse(OSHttpResponse httpResponse) + private byte[] OKResponse(IOSHttpResponse httpResponse) { m_log.Debug("[HELO]: hi, GET was called"); httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType); @@ -92,12 +92,12 @@ namespace OpenSim.Server.Handlers.Hypergrid } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { return OKResponse(httpResponse); } - private byte[] OKResponse(OSHttpResponse httpResponse) + private byte[] OKResponse(IOSHttpResponse httpResponse) { m_log.Debug("[HELO]: hi, HEAD was called"); httpResponse.AddHeader("X-Handlers-Provided", m_HandlersType); diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs index 850bf14..231e32f 100644 --- a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs +++ b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Inventory } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { XmlSerializer xs = new XmlSerializer(typeof (List)); List items = (List)xs.Deserialize(request); diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 899f9c0..9d6f964 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs @@ -88,7 +88,7 @@ namespace OpenSim.Server.Handlers.Asset } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index 8291107..75dd711 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs @@ -77,7 +77,7 @@ namespace OpenSim.Server.Handlers.MapImage m_MapService = service; } - public override byte[] Handle(string path, Stream requestData, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); StreamReader sr = new StreamReader(requestData); diff --git a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs index 501074d..fb85d1c 100644 --- a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs @@ -80,7 +80,7 @@ namespace OpenSim.Server.Handlers.MapImage m_MapService = service; } - public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { byte[] result = new byte[0]; diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs index 68bb01e..8a1f824 100644 --- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs +++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs @@ -59,7 +59,7 @@ namespace OpenSim.Server.Handlers.Neighbour } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // Not implemented yet Console.WriteLine("--- Get region --- " + path); @@ -84,7 +84,7 @@ namespace OpenSim.Server.Handlers.Neighbour } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { byte[] result = new byte[0]; @@ -177,7 +177,7 @@ namespace OpenSim.Server.Handlers.Neighbour } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // Not implemented yet httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; @@ -198,7 +198,7 @@ namespace OpenSim.Server.Handlers.Neighbour } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // Not implemented yet httpResponse.StatusCode = (int)HttpStatusCode.NotImplemented; diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 85bf96e..6b6a552 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Presence } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index fdb4967..1d1f9ef 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -249,7 +249,7 @@ namespace OpenSim.Server.Handlers.Simulation } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[SIMULATION]: Stream handler called"); @@ -436,7 +436,7 @@ namespace OpenSim.Server.Handlers.Simulation } public override byte[] Handle(string path, Stream request, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[SIMULATION]: Stream handler called"); diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index 5ab4caf..ab383ef 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs @@ -69,7 +69,7 @@ namespace OpenSim.Server.Handlers.UserAccounts } public override byte[] Handle(string path, Stream requestData, - OSHttpRequest httpRequest, OSHttpResponse httpResponse) + IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { StreamReader sr = new StreamReader(requestData); string body = sr.ReadToEnd(); diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs index 581985a..e10fe82 100644 --- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs +++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs @@ -27,25 +27,107 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; +using System.Web; using OpenSim.Framework.Servers.HttpServer; namespace OpenSim.Tests.Common.Mock { - public class TestOSHttpResponse : OSHttpResponse + public class TestOSHttpResponse : IOSHttpResponse { - private int m_statusCode; - public override int StatusCode - { - get { return m_statusCode; } - set { m_statusCode = value; } - } - - private string m_contentType; - public override string ContentType - { - get { return m_contentType; } - set { m_contentType = value; } - } + /// + /// Content type property. + /// + /// + /// Setting this property will also set IsContentTypeSet to + /// true. + /// + public string ContentType { get; set; } + + /// + /// Boolean property indicating whether the content type + /// property actively has been set. + /// + /// + /// IsContentTypeSet will go away together with .NET base. + /// + // public bool IsContentTypeSet + // { + // get { return _contentTypeSet; } + // } + // private bool _contentTypeSet; + + /// + /// Length of the body content; 0 if there is no body. + /// + public long ContentLength { get; set; } + + /// + /// Alias for ContentLength. + /// + public long ContentLength64 { get; set; } + + /// + /// Encoding of the body content. + /// + public Encoding ContentEncoding { get; set; } + + public bool KeepAlive { get; set; } + + /// + /// Get or set the keep alive timeout property (default is + /// 20). Setting this to 0 also disables KeepAlive. Setting + /// this to something else but 0 also enable KeepAlive. + /// + public int KeepAliveTimeout { get; set; } + + /// + /// Return the output stream feeding the body. + /// + /// + /// On its way out... + /// + public Stream OutputStream { get; private set; } + + public string ProtocolVersion { get; set; } + + /// + /// Return the output stream feeding the body. + /// + public Stream Body { get; private set; } + + /// + /// Set a redirct location. + /// + public string RedirectLocation { private get; set; } + + /// + /// Chunk transfers. + /// + public bool SendChunked { get; set; } + + /// + /// HTTP status code. + /// + public int StatusCode { get; set; } + + /// + /// HTTP status description. + /// + public string StatusDescription { get; set; } + + public bool ReuseContext { get; set; } + + /// + /// Add a header field and content to the response. + /// + /// string containing the header field + /// name + /// string containing the header field + /// value + public void AddHeader(string key, string value) { throw new NotImplementedException(); } + + public void Send() { } } -} +} \ No newline at end of file diff --git a/prebuild.xml b/prebuild.xml index 4e36172..05d9545 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2677,9 +2677,11 @@ ../../../bin/ + - + + @@ -2726,6 +2728,7 @@ + -- cgit v1.1