From ec0d2c28fa04102ecbad4c5660efecbb970201dd Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 4 May 2009 20:19:21 +0000 Subject: Committing the changed tree --- .../Servers/HttpServer/BaseRequestHandler.cs | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs new file mode 100644 index 0000000..9334972 --- /dev/null +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace OpenSim.Framework.Servers.HttpServer +{ + public class BaseRequestHandler + { + public virtual string ContentType + { + get { return "application/xml"; } + } + + private readonly string m_httpMethod; + + public virtual string HttpMethod + { + get { return m_httpMethod; } + } + + private readonly string m_path; + + protected BaseRequestHandler(string httpMethod, string path) + { + m_httpMethod = httpMethod; + m_path = path; + } + + public virtual string Path + { + get { return m_path; } + } + + protected string GetParam(string path) + { + try + { + return path.Substring(m_path.Length); + } + catch (Exception) + { + return String.Empty; + } + } + } +} -- cgit v1.1 From 1afdf2ee1fda020926d85f2763617b0bace5d03a Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 6 May 2009 17:02:51 +0000 Subject: * Added some GetAssetStreamHandlerTests * Minor tweaks to attain testability --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index 9334972..5ad4520 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -29,7 +29,7 @@ using System; namespace OpenSim.Framework.Servers.HttpServer { - public class BaseRequestHandler + public abstract class BaseRequestHandler { public virtual string ContentType { @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Servers.HttpServer get { return m_path; } } - protected string GetParam(string path) + public string GetParam(string path) { try { -- cgit v1.1 From f3db3d6a001abdca53d88def7a22a40d6aa30271 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 7 May 2009 06:31:16 +0000 Subject: * Added some more GetAssetStreamHandlerTests * In the process, caught a potential bug where the handler would allow paths not starting with the registered prefix --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index 5ad4520..da4f9a8 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -58,14 +58,22 @@ namespace OpenSim.Framework.Servers.HttpServer public string GetParam(string path) { - try + if (CheckParam(path)) { return path.Substring(m_path.Length); } - catch (Exception) + + return String.Empty; + } + + protected bool CheckParam(string path) + { + if(String.IsNullOrEmpty(path)) { - return String.Empty; + return false; } + + return path.StartsWith(Path); } } } -- cgit v1.1 From 8ac73be9178ac9b7445534522f5b574df29fa560 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Fri, 8 May 2009 06:11:44 +0000 Subject: * Introduced new HttpServer.Tests project * Split the GetAssetStreamHandler testing into separate tests for BaseRequestHandler * Ignored some gens --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index da4f9a8..c47a44a 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -75,5 +75,12 @@ namespace OpenSim.Framework.Servers.HttpServer return path.StartsWith(Path); } + + public string[] SplitParams(string path) + { + string param = GetParam(path); + + return param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); + } } } -- cgit v1.1 From e0bc5c5db2b88691c04b06be2fa73a75746126cb Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Wed, 20 May 2009 01:32:06 +0000 Subject: Add copyright headers, formatting cleanup. --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index c47a44a..d11259f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -68,7 +68,7 @@ namespace OpenSim.Framework.Servers.HttpServer protected bool CheckParam(string path) { - if(String.IsNullOrEmpty(path)) + if (String.IsNullOrEmpty(path)) { return false; } -- cgit v1.1 From 840de6c036570d559ec6924cd8405d3f34a99fdd Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 1 Jun 2009 06:37:14 +0000 Subject: Minor: Change OpenSim to OpenSimulator in older copyright headers and LICENSE.txt. --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index d11259f..a2135a3 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -9,7 +9,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSim Project nor the + * * 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. * -- cgit v1.1 From 231a3bf147315a9284140476d2b09e13c3fee1c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 May 2012 01:45:49 +0100 Subject: Implement optional name and description on http stream handlers so that we can relate a slow request to what the handler actually does and the agent it serves, if applicable. This is most useful for capabilities where the url is not self-describing. --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index a2135a3..ae7aaf2 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -45,8 +45,16 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly string m_path; - protected BaseRequestHandler(string httpMethod, string path) + public string Name { get; private set; } + + public string Description { get; private set; } + + protected BaseRequestHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} + + protected BaseRequestHandler(string httpMethod, string path, string name, string description) { + Name = name; + Description = description; m_httpMethod = httpMethod; m_path = path; } -- cgit v1.1 From e19defde36ddbd5ff90d8304c6fe3b57110f8078 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 22:03:07 +0100 Subject: Add "show caps stats by user" and "show caps stats by cap" console commands to print various counts of capability invocation by user and by cap This currently prints caps requests received and handled, so that overload of received compared to handled or deadlock can be detected. This involves making BaseStreamHandler and BaseOutputStream record the ints, which means inheritors should subclass ProcessRequest() instead of Handle() However, existing inheriting classes overriding Handle() will still work, albeit without stats recording. "show caps" becomes "show caps list" to disambiguate between show caps commands --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index ae7aaf2..bbac699 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -31,6 +31,10 @@ namespace OpenSim.Framework.Servers.HttpServer { public abstract class BaseRequestHandler { + public int RequestsReceived { get; protected set; } + + public int RequestsHandled { get; protected set; } + public virtual string ContentType { get { return "application/xml"; } -- cgit v1.1 From 8c5c9806d7cab87eba899b8d83a4767abacc9873 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Jul 2014 21:15:44 +0100 Subject: Add stats for service endpoints using existing data. For each service endpoint (e.g. posts to the xinventory service), a stat is available which shows the number of requests received and moving average per second The full name is "service.:.requests (e.g. service.POST:/xinventory.requests) --- OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index bbac699..72ffb0e 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -26,6 +26,7 @@ */ using System; +using OpenSim.Framework.Monitoring; namespace OpenSim.Framework.Servers.HttpServer { @@ -61,6 +62,19 @@ namespace OpenSim.Framework.Servers.HttpServer Description = description; m_httpMethod = httpMethod; m_path = path; + + StatsManager.RegisterStat( + new Stat( + "requests", + "requests", + "Number of requests received by this service endpoint", + "requests", + "service", + string.Format("{0}:{1}", httpMethod, path), + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + s => s.Value = RequestsReceived, + StatVerbosity.Debug)); } public virtual string Path -- cgit v1.1 From 1e3027afb18aa1d6dee3a498458da824fb79e88c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 26 Jul 2014 01:41:03 +0100 Subject: Temporary stop CAPS service points from being added to stats as this can be a huge number. A stop gap solution - a better one may be to improve stats display on simulator-side. Caps information is still accessible via the "show caps stats by user" and "show caps stats by cap" commands --- .../Servers/HttpServer/BaseRequestHandler.cs | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index 72ffb0e..d4a1ec3 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs @@ -63,18 +63,23 @@ namespace OpenSim.Framework.Servers.HttpServer m_httpMethod = httpMethod; m_path = path; - StatsManager.RegisterStat( - new Stat( - "requests", - "requests", - "Number of requests received by this service endpoint", - "requests", - "service", - string.Format("{0}:{1}", httpMethod, path), - StatType.Pull, - MeasuresOfInterest.AverageChangeOverTime, - s => s.Value = RequestsReceived, - StatVerbosity.Debug)); + // FIXME: A very temporary measure to stop the simulator stats being overwhelmed with user CAPS info. + // Needs to be fixed properly in stats display + if (!path.StartsWith("/CAPS/")) + { + StatsManager.RegisterStat( + new Stat( + "requests", + "requests", + "Number of requests received by this service endpoint", + "requests", + "service", + string.Format("{0}:{1}", httpMethod, path), + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + s => s.Value = RequestsReceived, + StatVerbosity.Debug)); + } } public virtual string Path -- cgit v1.1