diff options
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-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 8094b6d..a03d626 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,13 +726,15 @@ 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 | 737 | ||
711 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); | ||
712 | |||
713 | Type type = typeof(TRequest); | 738 | Type type = typeof(TRequest); |
714 | 739 | ||
715 | WebRequest request = WebRequest.Create(requestUrl); | 740 | WebRequest request = WebRequest.Create(requestUrl); |
@@ -866,7 +891,7 @@ namespace OpenSim.Framework | |||
866 | } | 891 | } |
867 | 892 | ||
868 | m_log.InfoFormat( | 893 | m_log.InfoFormat( |
869 | "[ASYNC REQUEST]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 894 | "[ASYNC REQUEST]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
870 | reqnum, | 895 | reqnum, |
871 | verb, | 896 | verb, |
872 | requestUrl, | 897 | requestUrl, |
@@ -874,6 +899,12 @@ namespace OpenSim.Framework | |||
874 | tickdata, | 899 | tickdata, |
875 | originalRequest); | 900 | originalRequest); |
876 | } | 901 | } |
902 | else if (WebUtil.DebugLevel >= 4) | ||
903 | { | ||
904 | m_log.DebugFormat( | ||
905 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
906 | reqnum, tickdiff, tickdata); | ||
907 | } | ||
877 | } | 908 | } |
878 | } | 909 | } |
879 | 910 | ||
@@ -894,7 +925,11 @@ namespace OpenSim.Framework | |||
894 | public static string MakeRequest(string verb, string requestUrl, string obj) | 925 | public static string MakeRequest(string verb, string requestUrl, string obj) |
895 | { | 926 | { |
896 | int reqnum = WebUtil.RequestNumber++; | 927 | int reqnum = WebUtil.RequestNumber++; |
897 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 928 | |
929 | if (WebUtil.DebugLevel >= 3) | ||
930 | m_log.DebugFormat( | ||
931 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}", | ||
932 | reqnum, verb, requestUrl); | ||
898 | 933 | ||
899 | int tickstart = Util.EnvironmentTickCount(); | 934 | int tickstart = Util.EnvironmentTickCount(); |
900 | int tickdata = 0; | 935 | int tickdata = 0; |
@@ -979,13 +1014,17 @@ namespace OpenSim.Framework | |||
979 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 1014 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); |
980 | if (tickdiff > WebUtil.LongCallTime) | 1015 | if (tickdiff > WebUtil.LongCallTime) |
981 | m_log.InfoFormat( | 1016 | m_log.InfoFormat( |
982 | "[FORMS]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 1017 | "[FORMS]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
983 | reqnum, | 1018 | reqnum, |
984 | verb, | 1019 | verb, |
985 | requestUrl, | 1020 | requestUrl, |
986 | tickdiff, | 1021 | tickdiff, |
987 | tickdata, | 1022 | tickdata, |
988 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1023 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1024 | else if (WebUtil.DebugLevel >= 4) | ||
1025 | m_log.DebugFormat( | ||
1026 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1027 | reqnum, tickdiff, tickdata); | ||
989 | 1028 | ||
990 | return respstring; | 1029 | return respstring; |
991 | } | 1030 | } |
@@ -1020,7 +1059,11 @@ namespace OpenSim.Framework | |||
1020 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) | 1059 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj, int pTimeout, int maxConnections) |
1021 | { | 1060 | { |
1022 | int reqnum = WebUtil.RequestNumber++; | 1061 | int reqnum = WebUtil.RequestNumber++; |
1023 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 1062 | |
1063 | if (WebUtil.DebugLevel >= 3) | ||
1064 | m_log.DebugFormat( | ||
1065 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}", | ||
1066 | reqnum, verb, requestUrl); | ||
1024 | 1067 | ||
1025 | int tickstart = Util.EnvironmentTickCount(); | 1068 | int tickstart = Util.EnvironmentTickCount(); |
1026 | int tickdata = 0; | 1069 | int tickdata = 0; |
@@ -1139,7 +1182,7 @@ namespace OpenSim.Framework | |||
1139 | } | 1182 | } |
1140 | 1183 | ||
1141 | m_log.InfoFormat( | 1184 | m_log.InfoFormat( |
1142 | "[SynchronousRestObjectRequester]: Slow request to <{0}> {1} {2} took {3}ms, {4}ms writing, {5}", | 1185 | "[SynchronousRestObjectRequester]: Slow request {0} {1} {2} took {3}ms, {4}ms writing, {5}", |
1143 | reqnum, | 1186 | reqnum, |
1144 | verb, | 1187 | verb, |
1145 | requestUrl, | 1188 | requestUrl, |
@@ -1147,6 +1190,12 @@ namespace OpenSim.Framework | |||
1147 | tickdata, | 1190 | tickdata, |
1148 | originalRequest); | 1191 | originalRequest); |
1149 | } | 1192 | } |
1193 | else if (WebUtil.DebugLevel >= 4) | ||
1194 | { | ||
1195 | m_log.DebugFormat( | ||
1196 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1197 | reqnum, tickdiff, tickdata); | ||
1198 | } | ||
1150 | 1199 | ||
1151 | return deserial; | 1200 | return deserial; |
1152 | } | 1201 | } |