aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorBlueWall2014-03-27 12:56:12 -0400
committerBlueWall2014-03-27 12:56:12 -0400
commit45ada5ca2db3478e423b9b0d11dd48ebaaf5ebcc (patch)
treeaa08b50386614d89e34baa4b5ada600dd900d565 /OpenSim/Framework
parentAdd support for specifying non-default StorageProvider (diff)
parentFixed a case where logging an HTTP response failed because the stream was non... (diff)
downloadopensim-SC_OLD-45ada5ca2db3478e423b9b0d11dd48ebaaf5ebcc.zip
opensim-SC_OLD-45ada5ca2db3478e423b9b0d11dd48ebaaf5ebcc.tar.gz
opensim-SC_OLD-45ada5ca2db3478e423b9b0d11dd48ebaaf5ebcc.tar.bz2
opensim-SC_OLD-45ada5ca2db3478e423b9b0d11dd48ebaaf5ebcc.tar.xz
Merge branch 'master' of /home/opensim/var/repo/opensim
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/WebUtil.cs51
1 files changed, 28 insertions, 23 deletions
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 89181a9..40c1634 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -41,6 +41,7 @@ using System.Xml;
41using System.Xml.Serialization; 41using System.Xml.Serialization;
42using log4net; 42using log4net;
43using OpenMetaverse.StructuredData; 43using OpenMetaverse.StructuredData;
44using XMLResponseHelper = OpenSim.Framework.SynchronousRestObjectRequester.XMLResponseHelper;
44 45
45namespace OpenSim.Framework 46namespace OpenSim.Framework
46{ 47{
@@ -793,7 +794,6 @@ namespace OpenSim.Framework
793 ht.ServicePoint.ConnectionLimit = maxConnections; 794 ht.ServicePoint.ConnectionLimit = maxConnections;
794 795
795 TResponse deserial = default(TResponse); 796 TResponse deserial = default(TResponse);
796 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
797 797
798 request.Method = verb; 798 request.Method = verb;
799 799
@@ -840,9 +840,7 @@ namespace OpenSim.Framework
840 { 840 {
841 using (Stream respStream = response.GetResponseStream()) 841 using (Stream respStream = response.GetResponseStream())
842 { 842 {
843 if (WebUtil.DebugLevel >= 5) 843 deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength);
844 WebUtil.LogResponseDetail(respStream);
845 deserial = (TResponse)deserializer.Deserialize(respStream);
846 } 844 }
847 } 845 }
848 catch (System.InvalidOperationException) 846 catch (System.InvalidOperationException)
@@ -869,9 +867,7 @@ namespace OpenSim.Framework
869 { 867 {
870 using (Stream respStream = response.GetResponseStream()) 868 using (Stream respStream = response.GetResponseStream())
871 { 869 {
872 if (WebUtil.DebugLevel >= 5) 870 deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, response.ContentLength);
873 WebUtil.LogResponseDetail(respStream);
874 deserial = (TResponse)deserializer.Deserialize(respStream);
875 } 871 }
876 } 872 }
877 catch (System.InvalidOperationException) 873 catch (System.InvalidOperationException)
@@ -1189,22 +1185,7 @@ namespace OpenSim.Framework
1189 { 1185 {
1190 using (Stream respStream = resp.GetResponseStream()) 1186 using (Stream respStream = resp.GetResponseStream())
1191 { 1187 {
1192 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 1188 deserial = XMLResponseHelper.LogAndDeserialize<TRequest, TResponse>(respStream, resp.ContentLength);
1193
1194 if (WebUtil.DebugLevel >= 5)
1195 {
1196 byte[] data = new byte[resp.ContentLength];
1197 Util.ReadStream(respStream, data);
1198
1199 WebUtil.LogResponseDetail(System.Text.Encoding.UTF8.GetString(data));
1200
1201 using (MemoryStream temp = new MemoryStream(data))
1202 deserial = (TResponse)deserializer.Deserialize(temp);
1203 }
1204 else
1205 {
1206 deserial = (TResponse)deserializer.Deserialize(respStream);
1207 }
1208 } 1189 }
1209 } 1190 }
1210 else 1191 else
@@ -1278,5 +1259,29 @@ namespace OpenSim.Framework
1278 1259
1279 return deserial; 1260 return deserial;
1280 } 1261 }
1262
1263
1264 public static class XMLResponseHelper
1265 {
1266 public static TResponse LogAndDeserialize<TRequest, TResponse>(Stream respStream, long contentLength)
1267 {
1268 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
1269
1270 if (WebUtil.DebugLevel >= 5)
1271 {
1272 byte[] data = new byte[contentLength];
1273 Util.ReadStream(respStream, data);
1274
1275 WebUtil.LogResponseDetail(System.Text.Encoding.UTF8.GetString(data));
1276
1277 using (MemoryStream temp = new MemoryStream(data))
1278 return (TResponse)deserializer.Deserialize(temp);
1279 }
1280 else
1281 {
1282 return (TResponse)deserializer.Deserialize(respStream);
1283 }
1284 }
1285 }
1281 } 1286 }
1282} 1287}