aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorOren Hurvitz2014-07-13 19:19:58 +0300
committerOren Hurvitz2014-07-21 09:24:45 +0100
commit6b57b6183603601d8bebf5c4cf5caced56d13242 (patch)
tree49a4c7503a50a60a58d9a07db7fa9b4fbef28ee7 /OpenSim/Framework/Communications
parentFixed problems if an avatar tries to cross regions when the previous cross ha... (diff)
downloadopensim-SC-6b57b6183603601d8bebf5c4cf5caced56d13242.zip
opensim-SC-6b57b6183603601d8bebf5c4cf5caced56d13242.tar.gz
opensim-SC-6b57b6183603601d8bebf5c4cf5caced56d13242.tar.bz2
opensim-SC-6b57b6183603601d8bebf5c4cf5caced56d13242.tar.xz
Log RestClient requests similarly to WebClient (e.g, "debug http all 6" logs the entire request and response)
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/RestClient.cs36
1 files changed, 30 insertions, 6 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