diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 4b69468..5211157 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> |
@@ -968,8 +972,9 @@ namespace OpenSim.Framework | |||
968 | requestStream = request.GetRequestStream(); | 972 | requestStream = request.GetRequestStream(); |
969 | requestStream.Write(buffer.ToArray(), 0, length); | 973 | requestStream.Write(buffer.ToArray(), 0, length); |
970 | } | 974 | } |
971 | catch (Exception) | 975 | catch (Exception e) |
972 | { | 976 | { |
977 | m_log.WarnFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e); | ||
973 | return deserial; | 978 | return deserial; |
974 | } | 979 | } |
975 | finally | 980 | finally |
@@ -983,19 +988,28 @@ namespace OpenSim.Framework | |||
983 | { | 988 | { |
984 | using (WebResponse resp = request.GetResponse()) | 989 | using (WebResponse resp = request.GetResponse()) |
985 | { | 990 | { |
986 | if (resp.ContentLength > 0) | 991 | if (resp.ContentLength != 0) |
987 | { | 992 | { |
988 | Stream respStream = resp.GetResponseStream(); | 993 | Stream respStream = resp.GetResponseStream(); |
989 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | 994 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); |
990 | deserial = (TResponse)deserializer.Deserialize(respStream); | 995 | deserial = (TResponse)deserializer.Deserialize(respStream); |
991 | respStream.Close(); | 996 | respStream.Close(); |
992 | } | 997 | } |
998 | else | ||
999 | m_log.WarnFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); | ||
1000 | |||
993 | } | 1001 | } |
994 | } | 1002 | } |
995 | catch (System.InvalidOperationException) | 1003 | catch (System.InvalidOperationException) |
996 | { | 1004 | { |
997 | // This is what happens when there is invalid XML | 1005 | // This is what happens when there is invalid XML |
1006 | m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString()); | ||
998 | } | 1007 | } |
1008 | catch (Exception e) | ||
1009 | { | ||
1010 | m_log.WarnFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e); | ||
1011 | } | ||
1012 | |||
999 | return deserial; | 1013 | return deserial; |
1000 | } | 1014 | } |
1001 | } | 1015 | } |