diff options
author | Justin Clarke Casey | 2009-06-05 16:14:22 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-06-05 16:14:22 +0000 |
commit | 593942b195cb5b29b47bd077cf53c32699fd2ff8 (patch) | |
tree | c2fc437583fd03468446f3680de41336bf62e8b3 /OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs | |
parent | * Add oar saving timeout (diff) | |
download | opensim-SC_OLD-593942b195cb5b29b47bd077cf53c32699fd2ff8.zip opensim-SC_OLD-593942b195cb5b29b47bd077cf53c32699fd2ff8.tar.gz opensim-SC_OLD-593942b195cb5b29b47bd077cf53c32699fd2ff8.tar.bz2 opensim-SC_OLD-593942b195cb5b29b47bd077cf53c32699fd2ff8.tar.xz |
* Fix problem where known missing assets would stop save oar ever completing
* Issue was that region server was silently dropping an XmlException caused by trying to deserialize the blank asset service response
* So make asset service return http status NOT FOUND rather than OK in accordance with REST
* and interpret this correctly in the async response so that a null object is sent back
* This means that this fix won't be active until both region simulator and server reach this revision
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs index 76d0b6f..fe69ad3 100644 --- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs +++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
38 | { | 38 | { |
39 | public class AsynchronousRestObjectRequester | 39 | public class AsynchronousRestObjectRequester |
40 | { | 40 | { |
41 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Perform an asynchronous REST request. | 44 | /// Perform an asynchronous REST request. |
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
56 | public static void MakeRequest<TRequest, TResponse>(string verb, | 56 | public static void MakeRequest<TRequest, TResponse>(string verb, |
57 | string requestUrl, TRequest obj, Action<TResponse> action) | 57 | string requestUrl, TRequest obj, Action<TResponse> action) |
58 | { | 58 | { |
59 | //m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} on {1}", verb, requestUrl); | 59 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); |
60 | 60 | ||
61 | Type type = typeof (TRequest); | 61 | Type type = typeof (TRequest); |
62 | 62 | ||
@@ -114,21 +114,61 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
114 | 114 | ||
115 | request.BeginGetResponse(delegate(IAsyncResult res2) | 115 | request.BeginGetResponse(delegate(IAsyncResult res2) |
116 | { | 116 | { |
117 | response = request.EndGetResponse(res2); | ||
118 | |||
119 | try | 117 | try |
120 | { | 118 | { |
121 | deserial = (TResponse) deserializer.Deserialize( | 119 | // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't |
122 | response.GetResponseStream()); | 120 | // documented in MSDN |
121 | response = request.EndGetResponse(res2); | ||
122 | |||
123 | try | ||
124 | { | ||
125 | deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); | ||
126 | } | ||
127 | catch (System.InvalidOperationException) | ||
128 | { | ||
129 | } | ||
130 | } | ||
131 | catch (WebException e) | ||
132 | { | ||
133 | if (e.Status == WebExceptionStatus.ProtocolError) | ||
134 | { | ||
135 | if (e.Response is HttpWebResponse) | ||
136 | { | ||
137 | HttpWebResponse httpResponse = (HttpWebResponse)e.Response; | ||
138 | |||
139 | if (httpResponse.StatusCode != HttpStatusCode.NotFound) | ||
140 | { | ||
141 | // We don't appear to be handling any other status codes, so log these feailures to that | ||
142 | // people don't spend unnecessary hours hunting phantom bugs. | ||
143 | m_log.DebugFormat( | ||
144 | "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}", | ||
145 | verb, requestUrl, httpResponse.StatusCode); | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); | ||
152 | } | ||
123 | } | 153 | } |
124 | catch (System.InvalidOperationException) | 154 | catch (Exception e) |
125 | { | 155 | { |
156 | m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); | ||
126 | } | 157 | } |
127 | 158 | ||
128 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); | 159 | // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString()); |
129 | 160 | ||
130 | action(deserial); | 161 | try |
131 | }, null); | 162 | { |
163 | action(deserial); | ||
164 | } | ||
165 | catch (Exception e) | ||
166 | { | ||
167 | m_log.ErrorFormat( | ||
168 | "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e); | ||
169 | } | ||
170 | |||
171 | }, null); | ||
132 | } | 172 | } |
133 | } | 173 | } |
134 | } | 174 | } |