diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 81 |
1 files changed, 65 insertions, 16 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 30a8c28..b85d93d 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -54,9 +54,17 @@ namespace OpenSim.Framework | |||
54 | MethodBase.GetCurrentMethod().DeclaringType); | 54 | MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
57 | /// Control the printing of certain debug messages. | ||
58 | /// </summary> | ||
59 | /// <remarks> | ||
60 | /// If DebugLevel >= 3 then short notices about outgoing HTTP requests are logged. | ||
61 | /// </remarks> | ||
62 | public static int DebugLevel { get; set; } | ||
63 | |||
64 | /// <summary> | ||
57 | /// Request number for diagnostic purposes. | 65 | /// Request number for diagnostic purposes. |
58 | /// </summary> | 66 | /// </summary> |
59 | public static int RequestNumber = 0; | 67 | public static int RequestNumber { get; internal set; } |
60 | 68 | ||
61 | /// <summary> | 69 | /// <summary> |
62 | /// this is the header field used to communicate the local request id | 70 | /// this is the header field used to communicate the local request id |
@@ -146,7 +154,11 @@ namespace OpenSim.Framework | |||
146 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | 154 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) |
147 | { | 155 | { |
148 | int reqnum = RequestNumber++; | 156 | int reqnum = RequestNumber++; |
149 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 157 | |
158 | if (DebugLevel >= 3) | ||
159 | m_log.DebugFormat( | ||
160 | "[WEB UTIL]: HTTP OUT {0} ServiceOSD {1} {2} (timeout {3}, compressed {4})", | ||
161 | reqnum, method, url, timeout, compressed); | ||
150 | 162 | ||
151 | string errorMessage = "unknown error"; | 163 | string errorMessage = "unknown error"; |
152 | int tickstart = Util.EnvironmentTickCount(); | 164 | int tickstart = Util.EnvironmentTickCount(); |
@@ -230,7 +242,7 @@ namespace OpenSim.Framework | |||
230 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 242 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
231 | if (tickdiff > LongCallTime) | 243 | if (tickdiff > LongCallTime) |
232 | m_log.InfoFormat( | 244 | m_log.InfoFormat( |
233 | "[OSD REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 245 | "[WEB UTIL]: Slow ServiceOSD request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
234 | reqnum, | 246 | reqnum, |
235 | method, | 247 | method, |
236 | url, | 248 | url, |
@@ -239,10 +251,14 @@ namespace OpenSim.Framework | |||
239 | strBuffer != null | 251 | strBuffer != null |
240 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | 252 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) |
241 | : ""); | 253 | : ""); |
254 | else if (DebugLevel >= 4) | ||
255 | m_log.DebugFormat( | ||
256 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
257 | reqnum, tickdiff, tickdata); | ||
242 | } | 258 | } |
243 | 259 | ||
244 | m_log.DebugFormat( | 260 | m_log.DebugFormat( |
245 | "[WEB UTIL]: <{0}> osd request for {1}, method {2} FAILED: {3}", reqnum, url, method, errorMessage); | 261 | "[WEB UTIL]: ServiceOSD request {0} {1} {2} FAILED: {3}", reqnum, url, method, errorMessage); |
246 | 262 | ||
247 | return ErrorResponseMap(errorMessage); | 263 | return ErrorResponseMap(errorMessage); |
248 | } | 264 | } |
@@ -318,7 +334,11 @@ namespace OpenSim.Framework | |||
318 | { | 334 | { |
319 | int reqnum = RequestNumber++; | 335 | int reqnum = RequestNumber++; |
320 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 336 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
321 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); | 337 | |
338 | if (DebugLevel >= 3) | ||
339 | m_log.DebugFormat( | ||
340 | "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", | ||
341 | reqnum, method, url, timeout); | ||
322 | 342 | ||
323 | string errorMessage = "unknown error"; | 343 | string errorMessage = "unknown error"; |
324 | int tickstart = Util.EnvironmentTickCount(); | 344 | int tickstart = Util.EnvironmentTickCount(); |
@@ -381,7 +401,7 @@ namespace OpenSim.Framework | |||
381 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 401 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
382 | if (tickdiff > LongCallTime) | 402 | if (tickdiff > LongCallTime) |
383 | m_log.InfoFormat( | 403 | m_log.InfoFormat( |
384 | "[SERVICE FORM]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 404 | "[WEB UTIL]: Slow ServiceForm request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
385 | reqnum, | 405 | reqnum, |
386 | method, | 406 | method, |
387 | url, | 407 | url, |
@@ -390,9 +410,13 @@ namespace OpenSim.Framework | |||
390 | queryString != null | 410 | queryString != null |
391 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString | 411 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString |
392 | : ""); | 412 | : ""); |
413 | else if (DebugLevel >= 4) | ||
414 | m_log.DebugFormat( | ||
415 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
416 | reqnum, tickdiff, tickdata); | ||
393 | } | 417 | } |
394 | 418 | ||
395 | m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); | 419 | m_log.WarnFormat("[WEB UTIL]: ServiceForm request {0} {1} {2} failed: {2}", reqnum, method, url, errorMessage); |
396 | 420 | ||
397 | return ErrorResponseMap(errorMessage); | 421 | return ErrorResponseMap(errorMessage); |
398 | } | 422 | } |
@@ -644,7 +668,6 @@ namespace OpenSim.Framework | |||
644 | /// <returns></returns> | 668 | /// <returns></returns> |
645 | public static string[] GetPreferredImageTypes(string accept) | 669 | public static string[] GetPreferredImageTypes(string accept) |
646 | { | 670 | { |
647 | |||
648 | if (accept == null || accept == string.Empty) | 671 | if (accept == null || accept == string.Empty) |
649 | return new string[0]; | 672 | return new string[0]; |
650 | 673 | ||
@@ -703,14 +726,16 @@ namespace OpenSim.Framework | |||
703 | int maxConnections) | 726 | int maxConnections) |
704 | { | 727 | { |
705 | int reqnum = WebUtil.RequestNumber++; | 728 | int reqnum = WebUtil.RequestNumber++; |
706 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 729 | |
730 | if (WebUtil.DebugLevel >= 3) | ||
731 | m_log.DebugFormat( | ||
732 | "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}", | ||
733 | reqnum, verb, requestUrl); | ||
707 | 734 | ||
708 | int tickstart = Util.EnvironmentTickCount(); | 735 | int tickstart = Util.EnvironmentTickCount(); |
709 | // int tickdata = 0; | 736 | // int tickdata = 0; |
710 | int tickdiff = 0; | 737 | int tickdiff = 0; |
711 | 738 | ||
712 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); | ||
713 | |||
714 | Type type = typeof(TRequest); | 739 | Type type = typeof(TRequest); |
715 | 740 | ||
716 | WebRequest request = WebRequest.Create(requestUrl); | 741 | WebRequest request = WebRequest.Create(requestUrl); |
@@ -868,7 +893,7 @@ namespace OpenSim.Framework | |||
868 | } | 893 | } |
869 | 894 | ||
870 | m_log.InfoFormat( | 895 | m_log.InfoFormat( |
871 | "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 896 | "[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
872 | reqnum, | 897 | reqnum, |
873 | verb, | 898 | verb, |
874 | requestUrl, | 899 | requestUrl, |
@@ -883,6 +908,12 @@ namespace OpenSim.Framework | |||
883 | requestUrl, | 908 | requestUrl, |
884 | tickdiff); | 909 | tickdiff); |
885 | } | 910 | } |
911 | else if (WebUtil.DebugLevel >= 4) | ||
912 | { | ||
913 | m_log.DebugFormat( | ||
914 | "[WEB UTIL]: HTTP OUT {0} took {1}ms", | ||
915 | reqnum, tickdiff); | ||
916 | } | ||
886 | } | 917 | } |
887 | } | 918 | } |
888 | 919 | ||
@@ -903,7 +934,11 @@ namespace OpenSim.Framework | |||
903 | public static string MakeRequest(string verb, string requestUrl, string obj) | 934 | public static string MakeRequest(string verb, string requestUrl, string obj) |
904 | { | 935 | { |
905 | int reqnum = WebUtil.RequestNumber++; | 936 | int reqnum = WebUtil.RequestNumber++; |
906 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 937 | |
938 | if (WebUtil.DebugLevel >= 3) | ||
939 | m_log.DebugFormat( | ||
940 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}", | ||
941 | reqnum, verb, requestUrl); | ||
907 | 942 | ||
908 | int tickstart = Util.EnvironmentTickCount(); | 943 | int tickstart = Util.EnvironmentTickCount(); |
909 | int tickdata = 0; | 944 | int tickdata = 0; |
@@ -990,7 +1025,7 @@ namespace OpenSim.Framework | |||
990 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 1025 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
991 | if (tickdiff > WebUtil.LongCallTime) | 1026 | if (tickdiff > WebUtil.LongCallTime) |
992 | m_log.InfoFormat( | 1027 | m_log.InfoFormat( |
993 | "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms {4}ms writing {5}", | 1028 | "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
994 | reqnum, | 1029 | reqnum, |
995 | verb, | 1030 | verb, |
996 | requestUrl, | 1031 | requestUrl, |
@@ -998,6 +1033,10 @@ namespace OpenSim.Framework | |||
998 | tickset, | 1033 | tickset, |
999 | tickdata, | 1034 | tickdata, |
1000 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1035 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1036 | else if (WebUtil.DebugLevel >= 4) | ||
1037 | m_log.DebugFormat( | ||
1038 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1039 | reqnum, tickdiff, tickdata); | ||
1001 | 1040 | ||
1002 | return respstring; | 1041 | return respstring; |
1003 | } | 1042 | } |
@@ -1032,7 +1071,11 @@ namespace OpenSim.Framework | |||
1032 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) | 1071 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) |
1033 | { | 1072 | { |
1034 | int reqnum = WebUtil.RequestNumber++; | 1073 | int reqnum = WebUtil.RequestNumber++; |
1035 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 1074 | |
1075 | if (WebUtil.DebugLevel >= 3) | ||
1076 | m_log.DebugFormat( | ||
1077 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}", | ||
1078 | reqnum, verb, requestUrl); | ||
1036 | 1079 | ||
1037 | int tickstart = Util.EnvironmentTickCount(); | 1080 | int tickstart = Util.EnvironmentTickCount(); |
1038 | int tickdata = 0; | 1081 | int tickdata = 0; |
@@ -1151,7 +1194,7 @@ namespace OpenSim.Framework | |||
1151 | } | 1194 | } |
1152 | 1195 | ||
1153 | m_log.InfoFormat( | 1196 | m_log.InfoFormat( |
1154 | "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 1197 | "[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
1155 | reqnum, | 1198 | reqnum, |
1156 | verb, | 1199 | verb, |
1157 | requestUrl, | 1200 | requestUrl, |
@@ -1159,6 +1202,12 @@ namespace OpenSim.Framework | |||
1159 | tickdata, | 1202 | tickdata, |
1160 | originalRequest); | 1203 | originalRequest); |
1161 | } | 1204 | } |
1205 | else if (WebUtil.DebugLevel >= 4) | ||
1206 | { | ||
1207 | m_log.DebugFormat( | ||
1208 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1209 | reqnum, tickdiff, tickdata); | ||
1210 | } | ||
1162 | 1211 | ||
1163 | return deserial; | 1212 | return deserial; |
1164 | } | 1213 | } |