diff --git a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs index 83a567635a..8372ae7af1 100644 --- a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs +++ b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework.Servers if (!UUID.TryParse(p[0], out assetID)) { - m_log.InfoFormat( + m_log.DebugFormat( "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]); return result; } @@ -91,12 +91,14 @@ namespace OpenSim.Framework.Servers } else { + m_log.DebugFormat("[REST]: GET:/asset failed to find {0}", assetID); + + httpResponse.StatusCode = (int)HttpStatusCode.NotFound; + if (StatsManager.AssetStats != null) { StatsManager.AssetStats.AddNotFoundRequest(); } - - m_log.InfoFormat("[REST]: GET:/asset failed to find {0}", assetID); } } diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs index 76d0b6fe9d..fe69ad35d8 100644 --- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs @@ -38,7 +38,7 @@ namespace OpenSim.Framework.Servers.HttpServer { public class AsynchronousRestObjectRequester { - //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); /// /// Perform an asynchronous REST request. @@ -56,7 +56,7 @@ namespace OpenSim.Framework.Servers.HttpServer public static void MakeRequest(string verb, string requestUrl, TRequest obj, Action action) { - //m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} on {1}", verb, requestUrl); +// m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); Type type = typeof (TRequest); @@ -114,21 +114,61 @@ namespace OpenSim.Framework.Servers.HttpServer request.BeginGetResponse(delegate(IAsyncResult res2) { - response = request.EndGetResponse(res2); + try + { + // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't + // documented in MSDN + response = request.EndGetResponse(res2); + + try + { + deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); + } + catch (System.InvalidOperationException) + { + } + } + catch (WebException e) + { + if (e.Status == WebExceptionStatus.ProtocolError) + { + if (e.Response is HttpWebResponse) + { + HttpWebResponse httpResponse = (HttpWebResponse)e.Response; + + if (httpResponse.StatusCode != HttpStatusCode.NotFound) + { + // We don't appear to be handling any other status codes, so log these feailures to that + // people don't spend unnecessary hours hunting phantom bugs. + m_log.DebugFormat( + "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", + verb, requestUrl, httpResponse.StatusCode); + } + } + } + else + { + m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); + } + } + catch (Exception e) + { + m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); + } + + // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); try { - deserial = (TResponse) deserializer.Deserialize( - response.GetResponseStream()); + action(deserial); } - catch (System.InvalidOperationException) + catch (Exception e) { + m_log.ErrorFormat( + "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e); } - - // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); - - action(deserial); - }, null); + + }, null); } } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 14804a4e33..fbb9a00ba6 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -228,12 +228,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver } if (asset != null) - { + { +// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as found", id); m_foundAssetUuids.Add(asset.FullID); m_assetsArchiver.WriteAsset(asset); } else { +// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id); m_notFoundAssetUuids.Add(new UUID(id)); }