diff options
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 2aa4af5..64d61f1 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -54,6 +54,14 @@ 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 = 0; |
@@ -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(); |
@@ -238,6 +250,10 @@ namespace OpenSim.Framework | |||
238 | strBuffer != null | 250 | strBuffer != null |
239 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) | 251 | ? (strBuffer.Length > MaxRequestDiagLength ? strBuffer.Remove(MaxRequestDiagLength) : strBuffer) |
240 | : ""); | 252 | : ""); |
253 | else if (DebugLevel >= 4) | ||
254 | m_log.DebugFormat( | ||
255 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
256 | reqnum, tickdiff, tickdata); | ||
241 | } | 257 | } |
242 | 258 | ||
243 | m_log.DebugFormat( | 259 | m_log.DebugFormat( |
@@ -317,7 +333,11 @@ namespace OpenSim.Framework | |||
317 | { | 333 | { |
318 | int reqnum = RequestNumber++; | 334 | int reqnum = RequestNumber++; |
319 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 335 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
320 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); | 336 | |
337 | if (DebugLevel >= 3) | ||
338 | m_log.DebugFormat( | ||
339 | "[WEB UTIL]: HTTP OUT {0} ServiceForm {1} {2} (timeout {3})", | ||
340 | reqnum, method, url, timeout); | ||
321 | 341 | ||
322 | string errorMessage = "unknown error"; | 342 | string errorMessage = "unknown error"; |
323 | int tickstart = Util.EnvironmentTickCount(); | 343 | int tickstart = Util.EnvironmentTickCount(); |
@@ -389,6 +409,10 @@ namespace OpenSim.Framework | |||
389 | queryString != null | 409 | queryString != null |
390 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString | 410 | ? (queryString.Length > MaxRequestDiagLength) ? queryString.Remove(MaxRequestDiagLength) : queryString |
391 | : ""); | 411 | : ""); |
412 | else if (DebugLevel >= 4) | ||
413 | m_log.DebugFormat( | ||
414 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
415 | reqnum, tickdiff, tickdata); | ||
392 | } | 416 | } |
393 | 417 | ||
394 | m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); | 418 | m_log.WarnFormat("[SERVICE FORM]: <{0}> form request to {1} failed: {2}", reqnum, url, errorMessage); |
@@ -643,7 +667,6 @@ namespace OpenSim.Framework | |||
643 | /// <returns></returns> | 667 | /// <returns></returns> |
644 | public static string[] GetPreferredImageTypes(string accept) | 668 | public static string[] GetPreferredImageTypes(string accept) |
645 | { | 669 | { |
646 | |||
647 | if (accept == null || accept == string.Empty) | 670 | if (accept == null || accept == string.Empty) |
648 | return new string[0]; | 671 | return new string[0]; |
649 | 672 | ||
@@ -695,13 +718,15 @@ namespace OpenSim.Framework | |||
695 | string requestUrl, TRequest obj, Action<TResponse> action) | 718 | string requestUrl, TRequest obj, Action<TResponse> action) |
696 | { | 719 | { |
697 | int reqnum = WebUtil.RequestNumber++; | 720 | int reqnum = WebUtil.RequestNumber++; |
698 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 721 | |
722 | if (WebUtil.DebugLevel >= 3) | ||
723 | m_log.DebugFormat( | ||
724 | "[WEB UTIL]: HTTP OUT {0} AsynchronousRequestObject {1} {2}", | ||
725 | reqnum, verb, requestUrl); | ||
699 | 726 | ||
700 | int tickstart = Util.EnvironmentTickCount(); | 727 | int tickstart = Util.EnvironmentTickCount(); |
701 | int tickdata = 0; | 728 | int tickdata = 0; |
702 | 729 | ||
703 | // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl); | ||
704 | |||
705 | Type type = typeof(TRequest); | 730 | Type type = typeof(TRequest); |
706 | 731 | ||
707 | WebRequest request = WebRequest.Create(requestUrl); | 732 | WebRequest request = WebRequest.Create(requestUrl); |
@@ -862,6 +887,12 @@ namespace OpenSim.Framework | |||
862 | tickdata, | 887 | tickdata, |
863 | originalRequest); | 888 | originalRequest); |
864 | } | 889 | } |
890 | else if (WebUtil.DebugLevel >= 4) | ||
891 | { | ||
892 | m_log.DebugFormat( | ||
893 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
894 | reqnum, tickdiff, tickdata); | ||
895 | } | ||
865 | } | 896 | } |
866 | } | 897 | } |
867 | 898 | ||
@@ -882,7 +913,11 @@ namespace OpenSim.Framework | |||
882 | public static string MakeRequest(string verb, string requestUrl, string obj) | 913 | public static string MakeRequest(string verb, string requestUrl, string obj) |
883 | { | 914 | { |
884 | int reqnum = WebUtil.RequestNumber++; | 915 | int reqnum = WebUtil.RequestNumber++; |
885 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 916 | |
917 | if (WebUtil.DebugLevel >= 3) | ||
918 | m_log.DebugFormat( | ||
919 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestForms {1} {2}", | ||
920 | reqnum, verb, requestUrl); | ||
886 | 921 | ||
887 | int tickstart = Util.EnvironmentTickCount(); | 922 | int tickstart = Util.EnvironmentTickCount(); |
888 | int tickdata = 0; | 923 | int tickdata = 0; |
@@ -974,6 +1009,10 @@ namespace OpenSim.Framework | |||
974 | tickdiff, | 1009 | tickdiff, |
975 | tickdata, | 1010 | tickdata, |
976 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); | 1011 | obj.Length > WebUtil.MaxRequestDiagLength ? obj.Remove(WebUtil.MaxRequestDiagLength) : obj); |
1012 | else if (WebUtil.DebugLevel >= 4) | ||
1013 | m_log.DebugFormat( | ||
1014 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1015 | reqnum, tickdiff, tickdata); | ||
977 | 1016 | ||
978 | return respstring; | 1017 | return respstring; |
979 | } | 1018 | } |
@@ -998,7 +1037,11 @@ namespace OpenSim.Framework | |||
998 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) | 1037 | public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) |
999 | { | 1038 | { |
1000 | int reqnum = WebUtil.RequestNumber++; | 1039 | int reqnum = WebUtil.RequestNumber++; |
1001 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 1040 | |
1041 | if (WebUtil.DebugLevel >= 3) | ||
1042 | m_log.DebugFormat( | ||
1043 | "[WEB UTIL]: HTTP OUT {0} SynchronousRestObject {1} {2}", | ||
1044 | reqnum, verb, requestUrl); | ||
1002 | 1045 | ||
1003 | int tickstart = Util.EnvironmentTickCount(); | 1046 | int tickstart = Util.EnvironmentTickCount(); |
1004 | int tickdata = 0; | 1047 | int tickdata = 0; |
@@ -1119,6 +1162,12 @@ namespace OpenSim.Framework | |||
1119 | tickdata, | 1162 | tickdata, |
1120 | originalRequest); | 1163 | originalRequest); |
1121 | } | 1164 | } |
1165 | else if (WebUtil.DebugLevel >= 4) | ||
1166 | { | ||
1167 | m_log.DebugFormat( | ||
1168 | "[WEB UTIL]: HTTP OUT {0} took {1}ms, {2}ms writing", | ||
1169 | reqnum, tickdiff, tickdata); | ||
1170 | } | ||
1122 | 1171 | ||
1123 | return deserial; | 1172 | return deserial; |
1124 | } | 1173 | } |