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. --- OpenSim/ApplicationPlugins/Rest/Regions/GETHandler.cs | 12 ++++++------ .../ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs | 4 ++-- OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs | 6 +++--- OpenSim/ApplicationPlugins/Rest/RestPlugin.cs | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/ApplicationPlugins') 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); -- cgit v1.1