* Log exceptions which make it up to the top of the http request frame, rather than having them disappear off into the ether
parent
af3118eccd
commit
48fc4ee059
|
@ -79,41 +79,31 @@ namespace OpenSim.Framework.Communications
|
|||
// See IInventoryServices
|
||||
public List<InventoryFolderBase> GetInventorySkeleton(LLUUID userId)
|
||||
{
|
||||
try
|
||||
m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId);
|
||||
|
||||
InventoryFolderBase rootFolder = RequestRootFolder(userId);
|
||||
|
||||
// Agent is completely new and has no inventory structure yet.
|
||||
if (null == rootFolder)
|
||||
{
|
||||
m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId);
|
||||
|
||||
List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>();
|
||||
|
||||
InventoryFolderBase rootFolder = RequestRootFolder(userId);
|
||||
|
||||
// Agent is completely new and has no inventory structure yet.
|
||||
if (null == rootFolder)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
userFolders.Add(rootFolder);
|
||||
|
||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||
{
|
||||
IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.folderID);
|
||||
userFolders.AddRange(folders);
|
||||
}
|
||||
|
||||
// foreach (InventoryFolderBase folder in userFolders)
|
||||
// {
|
||||
// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID);
|
||||
// }
|
||||
|
||||
return userFolders;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("GetInventorySkeleton() exception {0}", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
List<InventoryFolderBase> userFolders = new List<InventoryFolderBase>();
|
||||
userFolders.Add(rootFolder);
|
||||
|
||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||
{
|
||||
IList<InventoryFolderBase> folders = plugin.Value.getFolderHierarchy(rootFolder.folderID);
|
||||
userFolders.AddRange(folders);
|
||||
}
|
||||
|
||||
// foreach (InventoryFolderBase folder in userFolders)
|
||||
// {
|
||||
// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID);
|
||||
// }
|
||||
|
||||
return userFolders;
|
||||
}
|
||||
|
||||
// See IInventoryServices
|
||||
|
|
|
@ -123,73 +123,85 @@ namespace OpenSim.Framework.Servers
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle an individual http request. This method is given to a worker in the thread pool.
|
||||
/// </summary>
|
||||
/// <param name="stateinfo"></param>
|
||||
public virtual void HandleRequest(Object stateinfo)
|
||||
{
|
||||
HttpListenerContext context = (HttpListenerContext) stateinfo;
|
||||
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
|
||||
response.KeepAlive = false;
|
||||
response.SendChunked = false;
|
||||
|
||||
string path = request.RawUrl;
|
||||
string handlerKey = GetHandlerKey(request.HttpMethod, path);
|
||||
|
||||
IRequestHandler requestHandler;
|
||||
|
||||
if (TryGetStreamHandler(handlerKey, out requestHandler))
|
||||
// If we don't catch the exception here it will just disappear into the thread pool and we'll be none the wiser
|
||||
try
|
||||
{
|
||||
// Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
|
||||
byte[] buffer;
|
||||
if (requestHandler is IStreamedRequestHandler)
|
||||
HttpListenerContext context = (HttpListenerContext) stateinfo;
|
||||
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
|
||||
response.KeepAlive = false;
|
||||
response.SendChunked = false;
|
||||
|
||||
string path = request.RawUrl;
|
||||
string handlerKey = GetHandlerKey(request.HttpMethod, path);
|
||||
|
||||
IRequestHandler requestHandler;
|
||||
|
||||
if (TryGetStreamHandler(handlerKey, out requestHandler))
|
||||
{
|
||||
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
|
||||
buffer = streamedRequestHandler.Handle(path, request.InputStream);
|
||||
// Okay, so this is bad, but should be considered temporary until everything is IStreamHandler.
|
||||
byte[] buffer;
|
||||
if (requestHandler is IStreamedRequestHandler)
|
||||
{
|
||||
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
|
||||
buffer = streamedRequestHandler.Handle(path, request.InputStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
IStreamHandler streamHandler = (IStreamHandler) requestHandler;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
streamHandler.Handle(path, request.InputStream, memoryStream);
|
||||
memoryStream.Flush();
|
||||
buffer = memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
request.InputStream.Close();
|
||||
response.ContentType = requestHandler.ContentType;
|
||||
response.ContentLength64 = buffer.LongLength;
|
||||
|
||||
try
|
||||
{
|
||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
response.OutputStream.Close();
|
||||
}
|
||||
catch (HttpListenerException)
|
||||
{
|
||||
m_log.InfoFormat("[BASE HTTP SERVER] Http request abnormally terminated.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IStreamHandler streamHandler = (IStreamHandler) requestHandler;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
switch (request.ContentType)
|
||||
{
|
||||
streamHandler.Handle(path, request.InputStream, memoryStream);
|
||||
memoryStream.Flush();
|
||||
buffer = memoryStream.ToArray();
|
||||
case null:
|
||||
case "text/html":
|
||||
HandleHTTPRequest(request, response);
|
||||
break;
|
||||
case "application/xml+llsd":
|
||||
HandleLLSDRequests(request, response);
|
||||
break;
|
||||
case "text/xml":
|
||||
case "application/xml":
|
||||
default:
|
||||
HandleXmlRpcRequests(request, response);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
request.InputStream.Close();
|
||||
response.ContentType = requestHandler.ContentType;
|
||||
response.ContentLength64 = buffer.LongLength;
|
||||
|
||||
try
|
||||
{
|
||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||
response.OutputStream.Close();
|
||||
}
|
||||
catch (HttpListenerException)
|
||||
{
|
||||
m_log.InfoFormat("[BASEHTTPSERVER] Http request abnormally terminated.");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception e)
|
||||
{
|
||||
switch (request.ContentType)
|
||||
{
|
||||
case null:
|
||||
case "text/html":
|
||||
HandleHTTPRequest(request, response);
|
||||
break;
|
||||
case "application/xml+llsd":
|
||||
HandleLLSDRequests(request, response);
|
||||
break;
|
||||
case "text/xml":
|
||||
case "application/xml":
|
||||
default:
|
||||
HandleXmlRpcRequests(request, response);
|
||||
break;
|
||||
}
|
||||
m_log.ErrorFormat("[BASE HTTP SERVER]: HandleRequest() threw {0}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue