aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorOren Hurvitz2014-07-13 19:19:58 +0300
committerJustin Clark-Casey2014-08-02 00:57:04 +0100
commit9a2dc6a0d7b944a25d2ca090ae1e428ddef987f3 (patch)
tree85ee5123bde835b3acb148726cc6ba79d3c0c108
parentFixed problems if an avatar tries to cross regions when the previous cross ha... (diff)
downloadopensim-SC-9a2dc6a0d7b944a25d2ca090ae1e428ddef987f3.zip
opensim-SC-9a2dc6a0d7b944a25d2ca090ae1e428ddef987f3.tar.gz
opensim-SC-9a2dc6a0d7b944a25d2ca090ae1e428ddef987f3.tar.bz2
opensim-SC-9a2dc6a0d7b944a25d2ca090ae1e428ddef987f3.tar.xz
Log RestClient requests similarly to WebClient (e.g, "debug http all 6" logs the entire request and response)
-rw-r--r--OpenSim/Framework/Communications/RestClient.cs36
-rw-r--r--OpenSim/Framework/WebUtil.cs2
2 files changed, 31 insertions, 7 deletions
diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs
index fb79c59..de6fe30 100644
--- a/OpenSim/Framework/Communications/RestClient.cs
+++ b/OpenSim/Framework/Communications/RestClient.cs
@@ -347,6 +347,10 @@ namespace OpenSim.Framework.Communications
347 if (auth != null) 347 if (auth != null)
348 auth.AddAuthorization(_request.Headers); 348 auth.AddAuthorization(_request.Headers);
349 349
350 int reqnum = WebUtil.RequestNumber++;
351 if (WebUtil.DebugLevel >= 3)
352 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
353
350// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); 354// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
351 try 355 try
352 { 356 {
@@ -393,6 +397,9 @@ namespace OpenSim.Framework.Communications
393 _resource.Seek(0, SeekOrigin.Begin); 397 _resource.Seek(0, SeekOrigin.Begin);
394 } 398 }
395 399
400 if (WebUtil.DebugLevel >= 5)
401 WebUtil.LogResponseDetail(reqnum, _resource);
402
396 return _resource; 403 return _resource;
397 } 404 }
398 } 405 }
@@ -409,16 +416,18 @@ namespace OpenSim.Framework.Communications
409 if (auth != null) 416 if (auth != null)
410 auth.AddAuthorization(_request.Headers); 417 auth.AddAuthorization(_request.Headers);
411 418
412// m_log.DebugFormat("[REST]: Request Length {0}", _request.ContentLength);
413// m_log.DebugFormat("[REST]: Sending Web Request {0}", buildUri());
414 src.Seek(0, SeekOrigin.Begin); 419 src.Seek(0, SeekOrigin.Begin);
415// m_log.Debug("[REST]: Seek is ok"); 420
421 int reqnum = WebUtil.RequestNumber++;
422 if (WebUtil.DebugLevel >= 3)
423 m_log.DebugFormat("[LOGHTTP]: HTTP OUT {0} REST {1} to {2}", reqnum, _request.Method, _request.RequestUri);
424 if (WebUtil.DebugLevel >= 5)
425 WebUtil.LogOutgoingDetail(string.Format("SEND {0}: ", reqnum), src);
426
416 Stream dst = _request.GetRequestStream(); 427 Stream dst = _request.GetRequestStream();
417// m_log.Debug("[REST]: GetRequestStream is ok");
418 428
419 byte[] buf = new byte[1024]; 429 byte[] buf = new byte[1024];
420 int length = src.Read(buf, 0, 1024); 430 int length = src.Read(buf, 0, 1024);
421// m_log.Debug("[REST]: First Read is ok");
422 while (length > 0) 431 while (length > 0)
423 { 432 {
424 dst.Write(buf, 0, length); 433 dst.Write(buf, 0, length);
@@ -433,14 +442,29 @@ namespace OpenSim.Framework.Communications
433 { 442 {
434 m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}", 443 m_log.WarnFormat("[REST]: Request {0} {1} failed with status {2} and message {3}",
435 RequestMethod, _request.RequestUri, e.Status, e.Message); 444 RequestMethod, _request.RequestUri, e.Status, e.Message);
445 return null;
436 } 446 }
437 catch (Exception e) 447 catch (Exception e)
438 { 448 {
439 m_log.WarnFormat( 449 m_log.WarnFormat(
440 "[REST]: Request {0} {1} failed with exception {2} {3}", 450 "[REST]: Request {0} {1} failed with exception {2} {3}",
441 RequestMethod, _request.RequestUri, e.Message, e.StackTrace); 451 RequestMethod, _request.RequestUri, e.Message, e.StackTrace);
452 return null;
453 }
454
455 if (WebUtil.DebugLevel >= 5)
456 {
457 using (Stream responseStream = _response.GetResponseStream())
458 {
459 using (StreamReader reader = new StreamReader(responseStream))
460 {
461 string responseStr = reader.ReadToEnd();
462 WebUtil.LogResponseDetail(reqnum, responseStr);
463 }
464 }
442 } 465 }
443 466
467 _response.Close();
444 468
445// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request); 469// IAsyncResult responseAsyncResult = _request.BeginGetResponse(new AsyncCallback(ResponseIsReadyDelegate), _request);
446 470
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index d683152..b180c8a 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -69,7 +69,7 @@ namespace OpenSim.Framework
69 /// <summary> 69 /// <summary>
70 /// Request number for diagnostic purposes. 70 /// Request number for diagnostic purposes.
71 /// </summary> 71 /// </summary>
72 public static int RequestNumber { get; internal set; } 72 public static int RequestNumber { get; set; }
73 73
74 /// <summary> 74 /// <summary>
75 /// Control where OSD requests should be serialized per endpoint. 75 /// Control where OSD requests should be serialized per endpoint.