From e9e4c009b470056dce05cae386860494b0734678 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 11 May 2011 20:44:03 -0700 Subject: This makes compression of fatpacks actually work. Previously they always failed. See comment in WebUtil. --- OpenSim/Framework/WebUtil.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 55b38cd..bc2cd01 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -199,14 +199,14 @@ namespace OpenSim.Framework using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) { comp.Write(buffer, 0, buffer.Length); - comp.Flush(); - - ms.Seek(0, SeekOrigin.Begin); - - request.ContentLength = ms.Length; //Count bytes to send - using (Stream requestStream = request.GetRequestStream()) - requestStream.Write(ms.ToArray(), 0, (int)ms.Length); + // We need to close the gzip stream before we write it anywhere + // because apparently something important related to gzip compression + // gets written on the strteam upon Dispose() } + byte[] buf = ms.ToArray(); + request.ContentLength = buf.Length; //Count bytes to send + using (Stream requestStream = request.GetRequestStream()) + requestStream.Write(buf, 0, (int)buf.Length); } } else -- cgit v1.1 From f54a36bd592fec6571ddfda81d12a546583ab123 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 17:34:26 -0700 Subject: Tracking a problem with offline IMs coming in as null list. --- OpenSim/Framework/WebUtil.cs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index bc2cd01..2fd31d8 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -918,6 +918,10 @@ namespace OpenSim.Framework public class SynchronousRestObjectRequester { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + /// /// Perform a synchronous REST request. /// @@ -972,9 +976,9 @@ namespace OpenSim.Framework } } - try + using (WebResponse resp = request.GetResponse()) { - using (WebResponse resp = request.GetResponse()) + try { if (resp.ContentLength > 0) { @@ -984,10 +988,19 @@ namespace OpenSim.Framework respStream.Close(); } } - } - catch (System.InvalidOperationException) - { - // This is what happens when there is invalid XML + catch (System.InvalidOperationException) + { + // This is what happens when there is invalid XML + try + { + m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML:"); + using (StreamReader sr = new StreamReader(resp.GetResponseStream())) + m_log.WarnFormat("{0}", sr.ReadToEnd()); + } + catch (Exception e) + { } + + } } return deserial; } -- cgit v1.1 From 42bfab84b8a8197589bc60167a0f989492a37e17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 18:47:14 -0700 Subject: Bummer, can't print the data I wanted to see. Printing just the context. --- OpenSim/Framework/WebUtil.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 2fd31d8..0b99e82 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -991,15 +991,7 @@ namespace OpenSim.Framework catch (System.InvalidOperationException) { // This is what happens when there is invalid XML - try - { - m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML:"); - using (StreamReader sr = new StreamReader(resp.GetResponseStream())) - m_log.WarnFormat("{0}", sr.ReadToEnd()); - } - catch (Exception e) - { } - + m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); } } return deserial; -- cgit v1.1 From 9e310a0c0f9cbe06663fcd28fbd0ade3cb119d3d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 18:53:22 -0700 Subject: Sequencing the using and try clauses as they were before, but this shows that that obsolete function is not catching 404's as it should... --- OpenSim/Framework/WebUtil.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 0b99e82..e9a1e03 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -976,9 +976,9 @@ namespace OpenSim.Framework } } - using (WebResponse resp = request.GetResponse()) + try { - try + using (WebResponse resp = request.GetResponse()) { if (resp.ContentLength > 0) { @@ -988,11 +988,11 @@ namespace OpenSim.Framework respStream.Close(); } } - catch (System.InvalidOperationException) - { - // This is what happens when there is invalid XML - m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); - } + } + catch (System.InvalidOperationException) + { + // This is what happens when there is invalid XML + m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); } return deserial; } -- cgit v1.1 From 691283c44eed8343b0aae2bde9d21bd86e9c506a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 19:10:44 -0700 Subject: One more debug message for offline IMs. --- OpenSim/Framework/WebUtil.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index e9a1e03..cd93f71 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -965,8 +965,9 @@ namespace OpenSim.Framework requestStream = request.GetRequestStream(); requestStream.Write(buffer.ToArray(), 0, length); } - catch (Exception) + catch (Exception e) { + m_log.WarnFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e); return deserial; } finally -- cgit v1.1 From 301321c8535d702651eb8287bc2312df13562683 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 19:56:59 -0700 Subject: Instrument the heck out of offline messages. THIS IS VERY VERBOSE. --- OpenSim/Framework/WebUtil.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index cd93f71..511d660 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -940,6 +940,8 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; + m_log.DebugFormat("[XXX] 1"); + if ((verb == "POST") || (verb == "PUT")) { request.ContentType = "text/xml"; @@ -959,11 +961,14 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; + m_log.DebugFormat("[XXX] 2"); Stream requestStream = null; try { requestStream = request.GetRequestStream(); requestStream.Write(buffer.ToArray(), 0, length); + m_log.DebugFormat("[XXX] Wrote to stream ok"); + } catch (Exception e) { @@ -977,6 +982,8 @@ namespace OpenSim.Framework } } + m_log.DebugFormat("[XXX] Getting response now... {0}", requestUrl); + try { using (WebResponse resp = request.GetResponse()) @@ -988,6 +995,9 @@ namespace OpenSim.Framework deserial = (TResponse)deserializer.Deserialize(respStream); respStream.Close(); } + else + m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); + } } catch (System.InvalidOperationException) @@ -995,6 +1005,12 @@ namespace OpenSim.Framework // This is what happens when there is invalid XML m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); } + catch (Exception e) + { + m_log.WarnFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e); + } + + m_log.DebugFormat("[XXX] reply is null? {0}", (deserial == null) ? "yes": "no"); return deserial; } } -- cgit v1.1 From 1cc70df3b45f188f10c7c835bf89700d629203f0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 20:20:08 -0700 Subject: One more thing printed out. #OfflineIM --- OpenSim/Framework/WebUtil.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 511d660..8fd34cf 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -940,8 +940,6 @@ namespace OpenSim.Framework WebRequest request = WebRequest.Create(requestUrl); request.Method = verb; - m_log.DebugFormat("[XXX] 1"); - if ((verb == "POST") || (verb == "PUT")) { request.ContentType = "text/xml"; @@ -961,7 +959,6 @@ namespace OpenSim.Framework int length = (int)buffer.Length; request.ContentLength = length; - m_log.DebugFormat("[XXX] 2"); Stream requestStream = null; try { @@ -996,7 +993,7 @@ namespace OpenSim.Framework respStream.Close(); } else - m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); + m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}, ContentLength = {2}", requestUrl, verb, resp.ContentLength); } } -- cgit v1.1 From e39dec6f371bc9c0fbb92e010ee7fd8fbeef7d18 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 12 May 2011 20:48:24 -0700 Subject: Hopefully this fixes offline messages. The problem was: the server is not setting the ContentLength of the response. That comes up to OpenSim as ContentLength=-1, which made the existing test fail. --- OpenSim/Framework/WebUtil.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 8fd34cf..27a646a 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs @@ -964,8 +964,6 @@ namespace OpenSim.Framework { requestStream = request.GetRequestStream(); requestStream.Write(buffer.ToArray(), 0, length); - m_log.DebugFormat("[XXX] Wrote to stream ok"); - } catch (Exception e) { @@ -979,13 +977,11 @@ namespace OpenSim.Framework } } - m_log.DebugFormat("[XXX] Getting response now... {0}", requestUrl); - try { using (WebResponse resp = request.GetResponse()) { - if (resp.ContentLength > 0) + if (resp.ContentLength != 0) { Stream respStream = resp.GetResponseStream(); XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); @@ -993,7 +989,7 @@ namespace OpenSim.Framework respStream.Close(); } else - m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}, ContentLength = {2}", requestUrl, verb, resp.ContentLength); + m_log.WarnFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); } } @@ -1007,7 +1003,6 @@ namespace OpenSim.Framework m_log.WarnFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e); } - m_log.DebugFormat("[XXX] reply is null? {0}", (deserial == null) ? "yes": "no"); return deserial; } } -- cgit v1.1