From 882af7195ca6d7ac5f36f4121f65aab1302ad272 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 16 May 2014 13:18:04 +0300 Subject: Better error-handling and logging in case User Profile requests fail --- .../Servers/HttpServer/JsonRpcRequestManager.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs index ed6a14c..2fe1a7d 100644 --- a/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcRequestManager.cs @@ -90,14 +90,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -107,15 +107,15 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } if (!response.ContainsKey("result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } @@ -161,14 +161,14 @@ namespace OpenSim.Framework.Servers.HttpServer } catch (Exception e) { - m_log.Debug(string.Format("JsonRpc request '{0}' failed", method), e); + m_log.Debug(string.Format("JsonRpc request '{0}' to {1} failed", method, uri), e); return false; } if (!response.ContainsKey("_Result")) { - m_log.DebugFormat("JsonRpc request '{0}' returned an invalid response: {1}", - method, OSDParser.SerializeJsonString(response)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an invalid response: {2}", + method, uri, OSDParser.SerializeJsonString(response)); return false; } response = (OSDMap)response["_Result"]; @@ -176,8 +176,8 @@ namespace OpenSim.Framework.Servers.HttpServer if (response.ContainsKey("error")) { data = response["error"]; - m_log.DebugFormat("JsonRpc request '{0}' returned an error: {1}", - method, OSDParser.SerializeJsonString(data)); + m_log.DebugFormat("JsonRpc request '{0}' to {1} returned an error: {2}", + method, uri, OSDParser.SerializeJsonString(data)); return false; } -- cgit v1.1 From 20f20895cf1444071d5edc42e11a1fb94b1b1079 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 23 May 2014 16:19:43 -0700 Subject: Adds optional HTTP Basic Authentication to Robust service connectors. --- .../Framework/Servers/HttpServer/BaseStreamHandler.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Servers') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs index 252cc2a..f160734 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs @@ -26,6 +26,8 @@ */ using System.IO; +using System.Net; +using OpenSim.Framework.ServiceAuth; namespace OpenSim.Framework.Servers.HttpServer { @@ -37,15 +39,30 @@ namespace OpenSim.Framework.Servers.HttpServer /// public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler { - protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} + protected IServiceAuth m_Auth; + + protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) { } protected BaseStreamHandler(string httpMethod, string path, string name, string description) : base(httpMethod, path, name, description) {} + protected BaseStreamHandler(string httpMethod, string path, IServiceAuth auth) + : base(httpMethod, path, null, null) + { + m_Auth = auth; + } + public virtual byte[] Handle( string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { RequestsReceived++; + if (m_Auth != null && !m_Auth.Authenticate(httpRequest.Headers, httpResponse.AddHeader)) + { + + httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized; + httpResponse.ContentType = "text/plain"; + return new byte[0]; + } byte[] result = ProcessRequest(path, request, httpRequest, httpResponse); -- cgit v1.1