From 4567555c49cb560dd6f109bbfec42086af3de56f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 5 Dec 2011 20:44:20 +0000 Subject: [PATCH] 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. --- .../Rest/Regions/GETHandler.cs | 12 +- .../Rest/Regions/GETRegionInfoHandler.cs | 4 +- .../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 +- .../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 +- .../Servers/HttpServer/OSHttpRequest.cs | 3 +- .../Servers/HttpServer/OSHttpResponse.cs | 5 +- .../HttpServer/RestDeserialiseHandler.cs | 2 +- .../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 +- .../World/Land/LandManagementModule.cs | 4 +- .../World/Media/Moap/MoapModule.cs | 4 +- .../World/WorldMap/WorldMapModule.cs | 2 +- .../Region/DataSnapshot/DataRequestHandler.cs | 2 +- .../Framework/Scenes/RegionStatsHandler.cs | 2 +- .../FreeSwitchVoice/FreeSwitchVoiceModule.cs | 6 +- .../Voice/VivoxVoice/VivoxVoiceModule.cs | 6 +- .../WorldView/WorldViewRequestHandler.cs | 2 +- .../Region/UserStatistics/WebStatsModule.cs | 2 +- .../Asset/AssetServerDeleteHandler.cs | 2 +- .../Handlers/Asset/AssetServerGetHandler.cs | 2 +- .../Handlers/Asset/AssetServerPostHandler.cs | 2 +- .../AuthenticationServerPostHandler.cs | 2 +- .../Authentication/OpenIdServerHandler.cs | 2 +- .../AuthorizationServerPostHandler.cs | 2 +- .../Avatar/AvatarServerPostHandler.cs | 2 +- OpenSim/Server/Handlers/Base/Utils.cs | 2 +- .../Friends/FriendsServerPostHandler.cs | 2 +- .../Server/Handlers/Grid/GridInfoHandlers.cs | 2 +- .../Handlers/Grid/GridServerPostHandler.cs | 2 +- .../GridUser/GridUserServerPostHandler.cs | 2 +- .../Hypergrid/HGFriendsServerPostHandler.cs | 2 +- .../Handlers/Hypergrid/HeloServerConnector.cs | 8 +- .../InventoryServerMoveItemsHandler.cs | 2 +- .../Inventory/XInventoryInConnector.cs | 2 +- .../Handlers/Map/MapAddServerConnector.cs | 2 +- .../Handlers/Map/MapGetServerConnector.cs | 2 +- .../Handlers/Neighbour/NeighbourHandlers.cs | 8 +- .../Presence/PresenceServerPostHandler.cs | 2 +- .../Handlers/Simulation/AgentHandlers.cs | 4 +- .../UserAccountServerPostHandler.cs | 2 +- .../Tests/Common/Mock/TestOSHttpResponse.cs | 110 ++++++++++++-- prebuild.xml | 5 +- 56 files changed, 383 insertions(+), 103 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 dea166d2ec..d99ba57eb8 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 279db4cbe4..468faeaa50 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 e0318e52ea..f666f45e9a 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 ff1502ab34..eb167502b0 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 7ab30ceb27..ae95821dc2 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 b89fd6ab02..e0ccc3ced5 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 2dade5be94..a086c0e7ff 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 7aaa99403b..c7c1fc93db 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 db063f1778..4c381d0f86 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 04943d164a..f1cde747fc 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 bae4e1b997..1699233375 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 0000000000..caf0edd7c8 --- /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 0000000000..33a1663358 --- /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 2e1bc0b774..a449c2daa8 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 e354dfbd1a..fc8daf3732 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 702928992a..f9227ace62 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 3f2b2650b2..a467a83073 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 f97efbe6fe..80bc7ef251 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 7ebb462539..19c03a8e1a 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 2d43cd4b8b..d2c4002cd5 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 0a78df27ce..bae44eecda 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 98dda36273..2347cf2791 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 1b53a42dec..637beef677 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 21178275bc..94bba83bfb 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 898ca4a4c3..5239f50e78 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 95c727f0e5..9b0e2ffc79 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 a505999608..b7604546eb 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 45782364d2..6c5685c928 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 a5bba4f136..5323a95e9b 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 534bf929a4..70e2f7e267 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 f47d9c7228..550b5d437a 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 0251ee8473..fca9fd0884 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 8014fb5354..0cfe5b17de 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 43c1693471..8f7412bd77 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 1fcd3ed9ef..87b3d2dd32 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 4d1b0ff997..a19b5993bf 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 e73961bde1..440b898918 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 d656238cf0..bcf9d477e3 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 49c2e437e2..3ee405c509 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 92372a06f3..48d923f9ba 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 fc97d8c221..59420f5ca5 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 afe2f27c6b..645a77f086 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 edc05612db..bebf48242b 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 485bc3e911..4c0d52e722 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 56f130e2b8..661507e7e4 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 4accea1ecd..f306b1c757 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 850bf14b39..231e32f6fb 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 899f9c0979..9d6f964371 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 8291107c3d..75dd711ed2 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 501074dd4d..fb85d1ce1c 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 68bb01eea4..8a1f824dbd 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 85bf96e930..6b6a552448 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 fdb4967bba..1d1f9ef338 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 5ab4caf81f..ab383ef065 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 581985a7b9..e10fe8203e 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; } - } + /// + /// Content type property. + /// + /// + /// Setting this property will also set IsContentTypeSet to + /// true. + /// + public string ContentType { get; set; } - private string m_contentType; - public override string ContentType - { - get { return m_contentType; } - set { m_contentType = value; } - } + /// + /// 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 4e3617214d..05d9545004 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -2677,9 +2677,11 @@ ../../../bin/ + - + + @@ -2726,6 +2728,7 @@ +