aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/WebUtil.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/WebUtil.cs')
-rw-r--r--OpenSim/Framework/WebUtil.cs32
1 files changed, 23 insertions, 9 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 55b38cd..27a646a 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -199,14 +199,14 @@ namespace OpenSim.Framework
199 using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) 199 using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress))
200 { 200 {
201 comp.Write(buffer, 0, buffer.Length); 201 comp.Write(buffer, 0, buffer.Length);
202 comp.Flush(); 202 // We need to close the gzip stream before we write it anywhere
203 203 // because apparently something important related to gzip compression
204 ms.Seek(0, SeekOrigin.Begin); 204 // gets written on the strteam upon Dispose()
205
206 request.ContentLength = ms.Length; //Count bytes to send
207 using (Stream requestStream = request.GetRequestStream())
208 requestStream.Write(ms.ToArray(), 0, (int)ms.Length);
209 } 205 }
206 byte[] buf = ms.ToArray();
207 request.ContentLength = buf.Length; //Count bytes to send
208 using (Stream requestStream = request.GetRequestStream())
209 requestStream.Write(buf, 0, (int)buf.Length);
210 } 210 }
211 } 211 }
212 else 212 else
@@ -918,6 +918,10 @@ namespace OpenSim.Framework
918 918
919 public class SynchronousRestObjectRequester 919 public class SynchronousRestObjectRequester
920 { 920 {
921 private static readonly ILog m_log =
922 LogManager.GetLogger(
923 MethodBase.GetCurrentMethod().DeclaringType);
924
921 /// <summary> 925 /// <summary>
922 /// Perform a synchronous REST request. 926 /// Perform a synchronous REST request.
923 /// </summary> 927 /// </summary>
@@ -961,8 +965,9 @@ namespace OpenSim.Framework
961 requestStream = request.GetRequestStream(); 965 requestStream = request.GetRequestStream();
962 requestStream.Write(buffer.ToArray(), 0, length); 966 requestStream.Write(buffer.ToArray(), 0, length);
963 } 967 }
964 catch (Exception) 968 catch (Exception e)
965 { 969 {
970 m_log.WarnFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e);
966 return deserial; 971 return deserial;
967 } 972 }
968 finally 973 finally
@@ -976,19 +981,28 @@ namespace OpenSim.Framework
976 { 981 {
977 using (WebResponse resp = request.GetResponse()) 982 using (WebResponse resp = request.GetResponse())
978 { 983 {
979 if (resp.ContentLength > 0) 984 if (resp.ContentLength != 0)
980 { 985 {
981 Stream respStream = resp.GetResponseStream(); 986 Stream respStream = resp.GetResponseStream();
982 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 987 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
983 deserial = (TResponse)deserializer.Deserialize(respStream); 988 deserial = (TResponse)deserializer.Deserialize(respStream);
984 respStream.Close(); 989 respStream.Close();
985 } 990 }
991 else
992 m_log.WarnFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb);
993
986 } 994 }
987 } 995 }
988 catch (System.InvalidOperationException) 996 catch (System.InvalidOperationException)
989 { 997 {
990 // This is what happens when there is invalid XML 998 // This is what happens when there is invalid XML
999 m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString());
991 } 1000 }
1001 catch (Exception e)
1002 {
1003 m_log.WarnFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e);
1004 }
1005
992 return deserial; 1006 return deserial;
993 } 1007 }
994 } 1008 }