diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index b180c8a..3436984 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -233,6 +233,9 @@ namespace OpenSim.Framework | |||
233 | string errorMessage = "unknown error"; | 233 | string errorMessage = "unknown error"; |
234 | int tickstart = Util.EnvironmentTickCount(); | 234 | int tickstart = Util.EnvironmentTickCount(); |
235 | int tickdata = 0; | 235 | int tickdata = 0; |
236 | int tickcompressdata = 0; | ||
237 | int tickJsondata = 0; | ||
238 | int compsize = 0; | ||
236 | string strBuffer = null; | 239 | string strBuffer = null; |
237 | 240 | ||
238 | try | 241 | try |
@@ -250,6 +253,8 @@ namespace OpenSim.Framework | |||
250 | { | 253 | { |
251 | strBuffer = OSDParser.SerializeJsonString(data); | 254 | strBuffer = OSDParser.SerializeJsonString(data); |
252 | 255 | ||
256 | tickJsondata = Util.EnvironmentTickCountSubtract(tickstart); | ||
257 | |||
253 | if (DebugLevel >= 5) | 258 | if (DebugLevel >= 5) |
254 | LogOutgoingDetail("SEND", reqnum, strBuffer); | 259 | LogOutgoingDetail("SEND", reqnum, strBuffer); |
255 | 260 | ||
@@ -271,13 +276,20 @@ namespace OpenSim.Framework | |||
271 | // gets written on the stream upon Dispose() | 276 | // gets written on the stream upon Dispose() |
272 | } | 277 | } |
273 | byte[] buf = ms.ToArray(); | 278 | byte[] buf = ms.ToArray(); |
279 | |||
280 | tickcompressdata = Util.EnvironmentTickCountSubtract(tickstart); | ||
281 | |||
274 | request.ContentLength = buf.Length; //Count bytes to send | 282 | request.ContentLength = buf.Length; //Count bytes to send |
283 | compsize = buf.Length; | ||
275 | using (Stream requestStream = request.GetRequestStream()) | 284 | using (Stream requestStream = request.GetRequestStream()) |
276 | requestStream.Write(buf, 0, (int)buf.Length); | 285 | requestStream.Write(buf, 0, (int)buf.Length); |
277 | } | 286 | } |
278 | } | 287 | } |
279 | else | 288 | else |
280 | { | 289 | { |
290 | tickcompressdata = tickJsondata; | ||
291 | compsize = buffer.Length; | ||
292 | |||
281 | request.ContentLength = buffer.Length; //Count bytes to send | 293 | request.ContentLength = buffer.Length; //Count bytes to send |
282 | using (Stream requestStream = request.GetRequestStream()) | 294 | using (Stream requestStream = request.GetRequestStream()) |
283 | requestStream.Write(buffer, 0, buffer.Length); //Send it | 295 | requestStream.Write(buffer, 0, buffer.Length); //Send it |
@@ -314,6 +326,7 @@ namespace OpenSim.Framework | |||
314 | catch (Exception ex) | 326 | catch (Exception ex) |
315 | { | 327 | { |
316 | errorMessage = ex.Message; | 328 | errorMessage = ex.Message; |
329 | m_log.Debug("[WEB UTIL]: Exception making request: " + ex.ToString()); | ||
317 | } | 330 | } |
318 | finally | 331 | finally |
319 | { | 332 | { |
@@ -321,8 +334,17 @@ namespace OpenSim.Framework | |||
321 | if (tickdiff > LongCallTime) | 334 | if (tickdiff > LongCallTime) |
322 | { | 335 | { |
323 | m_log.InfoFormat( | 336 | m_log.InfoFormat( |
324 | "[LOGHTTP]: Slow JSON-RPC request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", | 337 | "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing({5} at Json; {6} at comp), {7} bytes ({8} uncomp): {9}", |
325 | reqnum, method, url, tickdiff, tickdata, | 338 | reqnum, |
339 | method, | ||
340 | url, | ||
341 | tickdiff, | ||
342 | tickdata, | ||
343 | tickJsondata, | ||
344 | tickcompressdata, | ||
345 | compsize, | ||
346 | strBuffer != null ? strBuffer.Length : 0, | ||
347 | |||
326 | strBuffer != null | 348 | strBuffer != null |
327 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | 349 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) |
328 | : ""); | 350 | : ""); |
@@ -396,7 +418,7 @@ namespace OpenSim.Framework | |||
396 | /// </summary> | 418 | /// </summary> |
397 | public static OSDMap PostToService(string url, NameValueCollection data) | 419 | public static OSDMap PostToService(string url, NameValueCollection data) |
398 | { | 420 | { |
399 | return ServiceFormRequest(url,data,10000); | 421 | return ServiceFormRequest(url,data, 30000); |
400 | } | 422 | } |
401 | 423 | ||
402 | public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) | 424 | public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) |
@@ -779,6 +801,20 @@ namespace OpenSim.Framework | |||
779 | MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null); | 801 | MakeRequest<TRequest, TResponse>(verb, requestUrl, obj, action, maxConnections, null); |
780 | } | 802 | } |
781 | 803 | ||
804 | /// <summary> | ||
805 | /// Perform a synchronous REST request. | ||
806 | /// </summary> | ||
807 | /// <param name="verb"></param> | ||
808 | /// <param name="requestUrl"></param> | ||
809 | /// <param name="obj"></param> | ||
810 | /// <param name="pTimeout"> | ||
811 | /// Request timeout in seconds. Timeout.Infinite indicates no timeout. If 0 is passed then the default HttpWebRequest timeout is used (100 seconds) | ||
812 | /// </param> | ||
813 | /// <param name="maxConnections"></param> | ||
814 | /// <returns> | ||
815 | /// The response. If there was an internal exception or the request timed out, | ||
816 | /// then the default(TResponse) is returned. | ||
817 | /// </returns> | ||
782 | public static void MakeRequest<TRequest, TResponse>(string verb, | 818 | public static void MakeRequest<TRequest, TResponse>(string verb, |
783 | string requestUrl, TRequest obj, Action<TResponse> action, | 819 | string requestUrl, TRequest obj, Action<TResponse> action, |
784 | int maxConnections, IServiceAuth auth) | 820 | int maxConnections, IServiceAuth auth) |
@@ -791,6 +827,7 @@ namespace OpenSim.Framework | |||
791 | 827 | ||
792 | int tickstart = Util.EnvironmentTickCount(); | 828 | int tickstart = Util.EnvironmentTickCount(); |
793 | int tickdata = 0; | 829 | int tickdata = 0; |
830 | int tickdiff = 0; | ||
794 | 831 | ||
795 | Type type = typeof(TRequest); | 832 | Type type = typeof(TRequest); |
796 | 833 | ||
@@ -936,7 +973,7 @@ namespace OpenSim.Framework | |||
936 | }, null); | 973 | }, null); |
937 | } | 974 | } |
938 | 975 | ||
939 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 976 | tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
940 | if (tickdiff > WebUtil.LongCallTime) | 977 | if (tickdiff > WebUtil.LongCallTime) |
941 | { | 978 | { |
942 | string originalRequest = null; | 979 | string originalRequest = null; |
@@ -948,8 +985,7 @@ namespace OpenSim.Framework | |||
948 | if (originalRequest.Length > WebUtil.MaxRequestDiagLength) | 985 | if (originalRequest.Length > WebUtil.MaxRequestDiagLength) |
949 | originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); | 986 | originalRequest = originalRequest.Remove(WebUtil.MaxRequestDiagLength); |
950 | } | 987 | } |
951 | 988 | m_log.InfoFormat( | |
952 | m_log.InfoFormat( | ||
953 | "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", | 989 | "[LOGHTTP]: Slow AsynchronousRequestObject request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", |
954 | reqnum, verb, requestUrl, tickdiff, tickdata, | 990 | reqnum, verb, requestUrl, tickdiff, tickdata, |
955 | originalRequest); | 991 | originalRequest); |
@@ -957,6 +993,7 @@ namespace OpenSim.Framework | |||
957 | else if (WebUtil.DebugLevel >= 4) | 993 | else if (WebUtil.DebugLevel >= 4) |
958 | { | 994 | { |
959 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", | 995 | m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} took {1}ms, {2}ms writing", |
996 | |||
960 | reqnum, tickdiff, tickdata); | 997 | reqnum, tickdiff, tickdata); |
961 | } | 998 | } |
962 | } | 999 | } |
@@ -1004,6 +1041,8 @@ namespace OpenSim.Framework | |||
1004 | 1041 | ||
1005 | string respstring = String.Empty; | 1042 | string respstring = String.Empty; |
1006 | 1043 | ||
1044 | int tickset = Util.EnvironmentTickCountSubtract(tickstart); | ||
1045 | |||
1007 | using (MemoryStream buffer = new MemoryStream()) | 1046 | using (MemoryStream buffer = new MemoryStream()) |
1008 | { | 1047 | { |
1009 | if ((verb == "POST") || (verb == "PUT")) | 1048 | if ((verb == "POST") || (verb == "PUT")) |
@@ -1070,8 +1109,13 @@ namespace OpenSim.Framework | |||
1070 | if (tickdiff > WebUtil.LongCallTime) | 1109 | if (tickdiff > WebUtil.LongCallTime) |
1071 | { | 1110 | { |
1072 | m_log.InfoFormat( | 1111 | m_log.InfoFormat( |
1073 | "[LOGHTTP]: Slow SynchronousRestForms request {0} {1} to {2} took {3}ms, {4}ms writing, {5}", | 1112 | "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
1074 | reqnum, verb, requestUrl, tickdiff, tickdata, | 1113 | reqnum, |
1114 | verb, | ||
1115 | requestUrl, | ||
1116 | tickdiff, | ||
1117 | tickset, | ||
1118 | tickdata, | ||
1075 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1119 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1076 | } | 1120 | } |
1077 | else if (WebUtil.DebugLevel >= 4) | 1121 | else if (WebUtil.DebugLevel >= 4) |
@@ -1202,7 +1246,7 @@ namespace OpenSim.Framework | |||
1202 | auth.AddAuthorization(ht.Headers); | 1246 | auth.AddAuthorization(ht.Headers); |
1203 | 1247 | ||
1204 | if (pTimeout != 0) | 1248 | if (pTimeout != 0) |
1205 | ht.Timeout = pTimeout; | 1249 | request.Timeout = pTimeout; |
1206 | 1250 | ||
1207 | if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) | 1251 | if (maxConnections > 0 && ht.ServicePoint.ConnectionLimit < maxConnections) |
1208 | ht.ServicePoint.ConnectionLimit = maxConnections; | 1252 | ht.ServicePoint.ConnectionLimit = maxConnections; |
@@ -1343,7 +1387,6 @@ namespace OpenSim.Framework | |||
1343 | 1387 | ||
1344 | return deserial; | 1388 | return deserial; |
1345 | } | 1389 | } |
1346 | |||
1347 | 1390 | ||
1348 | public static class XMLResponseHelper | 1391 | public static class XMLResponseHelper |
1349 | { | 1392 | { |