diff options
34 files changed, 418 insertions, 477 deletions
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs index c44b6cc..b3673da 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs | |||
@@ -215,18 +215,7 @@ namespace OpenSim.OfflineIM | |||
215 | 215 | ||
216 | rootElement.AppendChild(result); | 216 | rootElement.AppendChild(result); |
217 | 217 | ||
218 | return DocToBytes(doc); | 218 | return Util.DocToBytes(doc); |
219 | } | ||
220 | |||
221 | private byte[] DocToBytes(XmlDocument doc) | ||
222 | { | ||
223 | MemoryStream ms = new MemoryStream(); | ||
224 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
225 | xw.Formatting = Formatting.Indented; | ||
226 | doc.WriteTo(xw); | ||
227 | xw.Flush(); | ||
228 | |||
229 | return ms.ToArray(); | ||
230 | } | 219 | } |
231 | 220 | ||
232 | #endregion | 221 | #endregion |
diff --git a/OpenSim/Capabilities/LLSD.cs b/OpenSim/Capabilities/LLSD.cs index eec9e61..c59cede 100644 --- a/OpenSim/Capabilities/LLSD.cs +++ b/OpenSim/Capabilities/LLSD.cs | |||
@@ -68,7 +68,10 @@ namespace OpenSim.Framework.Capabilities | |||
68 | /// <returns></returns> | 68 | /// <returns></returns> |
69 | public static object LLSDDeserialize(byte[] b) | 69 | public static object LLSDDeserialize(byte[] b) |
70 | { | 70 | { |
71 | return LLSDDeserialize(new MemoryStream(b, false)); | 71 | using (MemoryStream ms = new MemoryStream(b, false)) |
72 | { | ||
73 | return LLSDDeserialize(ms); | ||
74 | } | ||
72 | } | 75 | } |
73 | 76 | ||
74 | /// <summary> | 77 | /// <summary> |
@@ -78,21 +81,23 @@ namespace OpenSim.Framework.Capabilities | |||
78 | /// <returns></returns> | 81 | /// <returns></returns> |
79 | public static object LLSDDeserialize(Stream st) | 82 | public static object LLSDDeserialize(Stream st) |
80 | { | 83 | { |
81 | XmlTextReader reader = new XmlTextReader(st); | 84 | using (XmlTextReader reader = new XmlTextReader(st)) |
82 | reader.Read(); | 85 | { |
83 | SkipWS(reader); | 86 | reader.Read(); |
87 | SkipWS(reader); | ||
84 | 88 | ||
85 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd") | 89 | if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "llsd") |
86 | throw new LLSDParseException("Expected <llsd>"); | 90 | throw new LLSDParseException("Expected <llsd>"); |
87 | 91 | ||
88 | reader.Read(); | 92 | reader.Read(); |
89 | object ret = LLSDParseOne(reader); | 93 | object ret = LLSDParseOne(reader); |
90 | SkipWS(reader); | 94 | SkipWS(reader); |
91 | 95 | ||
92 | if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd") | 96 | if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "llsd") |
93 | throw new LLSDParseException("Expected </llsd>"); | 97 | throw new LLSDParseException("Expected </llsd>"); |
94 | 98 | ||
95 | return ret; | 99 | return ret; |
100 | } | ||
96 | } | 101 | } |
97 | 102 | ||
98 | /// <summary> | 103 | /// <summary> |
diff --git a/OpenSim/Framework/Communications/RestClient.cs b/OpenSim/Framework/Communications/RestClient.cs index e556181..fb79c59 100644 --- a/OpenSim/Framework/Communications/RestClient.cs +++ b/OpenSim/Framework/Communications/RestClient.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Communications | |||
56 | /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be | 56 | /// other threads to execute, while it waits for a response from the web-service. RestClient itself can be |
57 | /// invoked by the caller in either synchronous mode or asynchronous modes. | 57 | /// invoked by the caller in either synchronous mode or asynchronous modes. |
58 | /// </remarks> | 58 | /// </remarks> |
59 | public class RestClient | 59 | public class RestClient : IDisposable |
60 | { | 60 | { |
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
62 | 62 | ||
@@ -148,6 +148,33 @@ namespace OpenSim.Framework.Communications | |||
148 | 148 | ||
149 | #endregion constructors | 149 | #endregion constructors |
150 | 150 | ||
151 | |||
152 | #region Dispose | ||
153 | |||
154 | private bool disposed = false; | ||
155 | |||
156 | public void Dispose() | ||
157 | { | ||
158 | Dispose(true); | ||
159 | GC.SuppressFinalize(this); | ||
160 | } | ||
161 | |||
162 | protected virtual void Dispose(bool disposing) | ||
163 | { | ||
164 | if (disposed) | ||
165 | return; | ||
166 | |||
167 | if (disposing) | ||
168 | { | ||
169 | _resource.Dispose(); | ||
170 | } | ||
171 | |||
172 | disposed = true; | ||
173 | } | ||
174 | |||
175 | #endregion Dispose | ||
176 | |||
177 | |||
151 | /// <summary> | 178 | /// <summary> |
152 | /// Add a path element to the query, e.g. assets | 179 | /// Add a path element to the query, e.g. assets |
153 | /// </summary> | 180 | /// </summary> |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b92c25b..093855c 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -832,28 +832,40 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
832 | return; // never log these; they're just binary data | 832 | return; // never log these; they're just binary data |
833 | 833 | ||
834 | Stream inputStream = Util.Copy(request.InputStream); | 834 | Stream inputStream = Util.Copy(request.InputStream); |
835 | 835 | Stream innerStream = null; | |
836 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) | 836 | try |
837 | inputStream = new GZipStream(inputStream, System.IO.Compression.CompressionMode.Decompress); | ||
838 | |||
839 | using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) | ||
840 | { | 837 | { |
841 | string output; | 838 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) |
842 | |||
843 | if (DebugLevel == 5) | ||
844 | { | 839 | { |
845 | char[] chars = new char[WebUtil.MaxRequestDiagLength + 1]; // +1 so we know to add "..." only if needed | 840 | innerStream = inputStream; |
846 | int len = reader.Read(chars, 0, WebUtil.MaxRequestDiagLength + 1); | 841 | inputStream = new GZipStream(innerStream, System.IO.Compression.CompressionMode.Decompress); |
847 | output = new string(chars, 0, Math.Min(len, WebUtil.MaxRequestDiagLength)); | ||
848 | if (len > WebUtil.MaxRequestDiagLength) | ||
849 | output += "..."; | ||
850 | } | 842 | } |
851 | else | 843 | |
844 | using (StreamReader reader = new StreamReader(inputStream, Encoding.UTF8)) | ||
852 | { | 845 | { |
853 | output = reader.ReadToEnd(); | 846 | string output; |
854 | } | ||
855 | 847 | ||
856 | m_log.DebugFormat("[LOGHTTP] {0}", Util.BinaryToASCII(output)); | 848 | if (DebugLevel == 5) |
849 | { | ||
850 | char[] chars = new char[WebUtil.MaxRequestDiagLength + 1]; // +1 so we know to add "..." only if needed | ||
851 | int len = reader.Read(chars, 0, WebUtil.MaxRequestDiagLength + 1); | ||
852 | output = new string(chars, 0, Math.Min(len, WebUtil.MaxRequestDiagLength)); | ||
853 | if (len > WebUtil.MaxRequestDiagLength) | ||
854 | output += "..."; | ||
855 | } | ||
856 | else | ||
857 | { | ||
858 | output = reader.ReadToEnd(); | ||
859 | } | ||
860 | |||
861 | m_log.DebugFormat("[LOGHTTP] {0}", Util.BinaryToASCII(output)); | ||
862 | } | ||
863 | } | ||
864 | finally | ||
865 | { | ||
866 | if (innerStream != null) | ||
867 | innerStream.Dispose(); | ||
868 | inputStream.Dispose(); | ||
857 | } | 869 | } |
858 | } | 870 | } |
859 | 871 | ||
@@ -981,19 +993,33 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
981 | /// <param name="response"></param> | 993 | /// <param name="response"></param> |
982 | private byte[] HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) | 994 | private byte[] HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) |
983 | { | 995 | { |
984 | Stream requestStream = request.InputStream; | 996 | String requestBody; |
985 | 997 | ||
986 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) | 998 | Stream requestStream = request.InputStream; |
987 | requestStream = new GZipStream(requestStream, System.IO.Compression.CompressionMode.Decompress); | 999 | Stream innerStream = null; |
1000 | try | ||
1001 | { | ||
1002 | if ((request.Headers["Content-Encoding"] == "gzip") || (request.Headers["X-Content-Encoding"] == "gzip")) | ||
1003 | { | ||
1004 | innerStream = requestStream; | ||
1005 | requestStream = new GZipStream(innerStream, System.IO.Compression.CompressionMode.Decompress); | ||
1006 | } | ||
988 | 1007 | ||
989 | Encoding encoding = Encoding.UTF8; | 1008 | using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) |
990 | StreamReader reader = new StreamReader(requestStream, encoding); | 1009 | { |
1010 | requestBody = reader.ReadToEnd(); | ||
1011 | } | ||
1012 | } | ||
1013 | finally | ||
1014 | { | ||
1015 | if (innerStream != null) | ||
1016 | innerStream.Dispose(); | ||
1017 | requestStream.Dispose(); | ||
1018 | } | ||
991 | 1019 | ||
992 | string requestBody = reader.ReadToEnd(); | ||
993 | reader.Close(); | ||
994 | requestStream.Close(); | ||
995 | //m_log.Debug(requestBody); | 1020 | //m_log.Debug(requestBody); |
996 | requestBody = requestBody.Replace("<base64></base64>", ""); | 1021 | requestBody = requestBody.Replace("<base64></base64>", ""); |
1022 | |||
997 | string responseString = String.Empty; | 1023 | string responseString = String.Empty; |
998 | XmlRpcRequest xmlRprcRequest = null; | 1024 | XmlRpcRequest xmlRprcRequest = null; |
999 | 1025 | ||
@@ -1089,18 +1115,16 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
1089 | 1115 | ||
1090 | response.ContentType = "text/xml"; | 1116 | response.ContentType = "text/xml"; |
1091 | using (MemoryStream outs = new MemoryStream()) | 1117 | using (MemoryStream outs = new MemoryStream()) |
1118 | using (XmlTextWriter writer = new XmlTextWriter(outs, Encoding.UTF8)) | ||
1092 | { | 1119 | { |
1093 | using (XmlTextWriter writer = new XmlTextWriter(outs, Encoding.UTF8)) | 1120 | writer.Formatting = Formatting.None; |
1121 | XmlRpcResponseSerializer.Singleton.Serialize(writer, xmlRpcResponse); | ||
1122 | writer.Flush(); | ||
1123 | outs.Flush(); | ||
1124 | outs.Position = 0; | ||
1125 | using (StreamReader sr = new StreamReader(outs)) | ||
1094 | { | 1126 | { |
1095 | writer.Formatting = Formatting.None; | 1127 | responseString = sr.ReadToEnd(); |
1096 | XmlRpcResponseSerializer.Singleton.Serialize(writer, xmlRpcResponse); | ||
1097 | writer.Flush(); | ||
1098 | outs.Flush(); | ||
1099 | outs.Position = 0; | ||
1100 | using (StreamReader sr = new StreamReader(outs)) | ||
1101 | { | ||
1102 | responseString = sr.ReadToEnd(); | ||
1103 | } | ||
1104 | } | 1128 | } |
1105 | } | 1129 | } |
1106 | } | 1130 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs index 48ced19..afe052f 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPoster.cs | |||
@@ -52,23 +52,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
52 | request.Method = verb; | 52 | request.Method = verb; |
53 | request.ContentType = "text/xml"; | 53 | request.ContentType = "text/xml"; |
54 | 54 | ||
55 | MemoryStream buffer = new MemoryStream(); | 55 | using (MemoryStream buffer = new MemoryStream()) |
56 | { | ||
57 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
58 | settings.Encoding = Encoding.UTF8; | ||
56 | 59 | ||
57 | XmlWriterSettings settings = new XmlWriterSettings(); | 60 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) |
58 | settings.Encoding = Encoding.UTF8; | 61 | { |
62 | XmlSerializer serializer = new XmlSerializer(type); | ||
63 | serializer.Serialize(writer, obj); | ||
64 | writer.Flush(); | ||
65 | } | ||
59 | 66 | ||
60 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | 67 | int length = (int)buffer.Length; |
61 | { | 68 | request.ContentLength = length; |
62 | XmlSerializer serializer = new XmlSerializer(type); | ||
63 | serializer.Serialize(writer, obj); | ||
64 | writer.Flush(); | ||
65 | } | ||
66 | 69 | ||
67 | int length = (int) buffer.Length; | 70 | using (Stream requestStream = request.GetRequestStream()) |
68 | request.ContentLength = length; | 71 | requestStream.Write(buffer.ToArray(), 0, length); |
72 | } | ||
69 | 73 | ||
70 | Stream requestStream = request.GetRequestStream(); | ||
71 | requestStream.Write(buffer.ToArray(), 0, length); | ||
72 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | 74 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); |
73 | request.BeginGetResponse(AsyncCallback, request); | 75 | request.BeginGetResponse(AsyncCallback, request); |
74 | } | 76 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs index 451745c..a911b9f 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestObjectPosterResponse.cs | |||
@@ -60,24 +60,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
60 | request.ContentType = "text/xml"; | 60 | request.ContentType = "text/xml"; |
61 | request.Timeout = 10000; | 61 | request.Timeout = 10000; |
62 | 62 | ||
63 | MemoryStream buffer = new MemoryStream(); | 63 | using (MemoryStream buffer = new MemoryStream()) |
64 | { | ||
65 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
66 | settings.Encoding = Encoding.UTF8; | ||
67 | |||
68 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
69 | { | ||
70 | XmlSerializer serializer = new XmlSerializer(type); | ||
71 | serializer.Serialize(writer, obj); | ||
72 | writer.Flush(); | ||
73 | } | ||
64 | 74 | ||
65 | XmlWriterSettings settings = new XmlWriterSettings(); | 75 | int length = (int)buffer.Length; |
66 | settings.Encoding = Encoding.UTF8; | 76 | request.ContentLength = length; |
67 | 77 | ||
68 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | 78 | using (Stream requestStream = request.GetRequestStream()) |
69 | { | 79 | requestStream.Write(buffer.ToArray(), 0, length); |
70 | XmlSerializer serializer = new XmlSerializer(type); | ||
71 | serializer.Serialize(writer, obj); | ||
72 | writer.Flush(); | ||
73 | } | 80 | } |
74 | 81 | ||
75 | int length = (int) buffer.Length; | ||
76 | request.ContentLength = length; | ||
77 | |||
78 | Stream requestStream = request.GetRequestStream(); | ||
79 | requestStream.Write(buffer.ToArray(), 0, length); | ||
80 | requestStream.Close(); | ||
81 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | 82 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); |
82 | request.BeginGetResponse(AsyncCallback, request); | 83 | request.BeginGetResponse(AsyncCallback, request); |
83 | } | 84 | } |
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs index 83c9848..ad69cd2 100644 --- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs +++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs | |||
@@ -77,25 +77,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
77 | request.ContentType = "text/xml"; | 77 | request.ContentType = "text/xml"; |
78 | request.Timeout = 20000; | 78 | request.Timeout = 20000; |
79 | 79 | ||
80 | MemoryStream buffer = new MemoryStream(); | 80 | using (MemoryStream buffer = new MemoryStream()) |
81 | |||
82 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
83 | settings.Encoding = Encoding.UTF8; | ||
84 | |||
85 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
86 | { | 81 | { |
87 | XmlSerializer serializer = new XmlSerializer(type); | 82 | XmlWriterSettings settings = new XmlWriterSettings(); |
88 | serializer.Serialize(writer, sobj); | 83 | settings.Encoding = Encoding.UTF8; |
89 | writer.Flush(); | ||
90 | } | ||
91 | 84 | ||
92 | int length = (int)buffer.Length; | 85 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) |
93 | request.ContentLength = length; | 86 | { |
87 | XmlSerializer serializer = new XmlSerializer(type); | ||
88 | serializer.Serialize(writer, sobj); | ||
89 | writer.Flush(); | ||
90 | } | ||
91 | |||
92 | int length = (int)buffer.Length; | ||
93 | request.ContentLength = length; | ||
94 | 94 | ||
95 | Stream requestStream = request.GetRequestStream(); | 95 | using (Stream requestStream = request.GetRequestStream()) |
96 | requestStream.Write(buffer.ToArray(), 0, length); | 96 | requestStream.Write(buffer.ToArray(), 0, length); |
97 | buffer.Close(); | 97 | } |
98 | requestStream.Close(); | ||
99 | 98 | ||
100 | TResponse deserial = default(TResponse); | 99 | TResponse deserial = default(TResponse); |
101 | using (WebResponse resp = request.GetResponse()) | 100 | using (WebResponse resp = request.GetResponse()) |
@@ -133,25 +132,25 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
133 | request.ContentType = "text/xml"; | 132 | request.ContentType = "text/xml"; |
134 | request.Timeout = 10000; | 133 | request.Timeout = 10000; |
135 | 134 | ||
136 | MemoryStream buffer = new MemoryStream(); | 135 | using (MemoryStream buffer = new MemoryStream()) |
136 | { | ||
137 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
138 | settings.Encoding = Encoding.UTF8; | ||
139 | |||
140 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
141 | { | ||
142 | XmlSerializer serializer = new XmlSerializer(type); | ||
143 | serializer.Serialize(writer, sobj); | ||
144 | writer.Flush(); | ||
145 | } | ||
137 | 146 | ||
138 | XmlWriterSettings settings = new XmlWriterSettings(); | 147 | int length = (int)buffer.Length; |
139 | settings.Encoding = Encoding.UTF8; | 148 | request.ContentLength = length; |
140 | 149 | ||
141 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | 150 | using (Stream requestStream = request.GetRequestStream()) |
142 | { | 151 | requestStream.Write(buffer.ToArray(), 0, length); |
143 | XmlSerializer serializer = new XmlSerializer(type); | ||
144 | serializer.Serialize(writer, sobj); | ||
145 | writer.Flush(); | ||
146 | } | 152 | } |
147 | buffer.Close(); | ||
148 | |||
149 | int length = (int)buffer.Length; | ||
150 | request.ContentLength = length; | ||
151 | 153 | ||
152 | Stream requestStream = request.GetRequestStream(); | ||
153 | requestStream.Write(buffer.ToArray(), 0, length); | ||
154 | requestStream.Close(); | ||
155 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | 154 | // IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); |
156 | request.BeginGetResponse(AsyncCallback, request); | 155 | request.BeginGetResponse(AsyncCallback, request); |
157 | } | 156 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 9d7de97..5c429ee 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -509,6 +509,19 @@ namespace OpenSim.Framework | |||
509 | return sb.ToString(); | 509 | return sb.ToString(); |
510 | } | 510 | } |
511 | 511 | ||
512 | public static byte[] DocToBytes(XmlDocument doc) | ||
513 | { | ||
514 | using (MemoryStream ms = new MemoryStream()) | ||
515 | using (XmlTextWriter xw = new XmlTextWriter(ms, null)) | ||
516 | { | ||
517 | xw.Formatting = Formatting.Indented; | ||
518 | doc.WriteTo(xw); | ||
519 | xw.Flush(); | ||
520 | |||
521 | return ms.ToArray(); | ||
522 | } | ||
523 | } | ||
524 | |||
512 | /// <summary> | 525 | /// <summary> |
513 | /// Is the platform Windows? | 526 | /// Is the platform Windows? |
514 | /// </summary> | 527 | /// </summary> |
@@ -1307,46 +1320,6 @@ namespace OpenSim.Framework | |||
1307 | return ret; | 1320 | return ret; |
1308 | } | 1321 | } |
1309 | 1322 | ||
1310 | public static string Compress(string text) | ||
1311 | { | ||
1312 | byte[] buffer = Util.UTF8.GetBytes(text); | ||
1313 | MemoryStream memory = new MemoryStream(); | ||
1314 | using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true)) | ||
1315 | { | ||
1316 | compressor.Write(buffer, 0, buffer.Length); | ||
1317 | } | ||
1318 | |||
1319 | memory.Position = 0; | ||
1320 | |||
1321 | byte[] compressed = new byte[memory.Length]; | ||
1322 | memory.Read(compressed, 0, compressed.Length); | ||
1323 | |||
1324 | byte[] compressedBuffer = new byte[compressed.Length + 4]; | ||
1325 | Buffer.BlockCopy(compressed, 0, compressedBuffer, 4, compressed.Length); | ||
1326 | Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, compressedBuffer, 0, 4); | ||
1327 | return Convert.ToBase64String(compressedBuffer); | ||
1328 | } | ||
1329 | |||
1330 | public static string Decompress(string compressedText) | ||
1331 | { | ||
1332 | byte[] compressedBuffer = Convert.FromBase64String(compressedText); | ||
1333 | using (MemoryStream memory = new MemoryStream()) | ||
1334 | { | ||
1335 | int msgLength = BitConverter.ToInt32(compressedBuffer, 0); | ||
1336 | memory.Write(compressedBuffer, 4, compressedBuffer.Length - 4); | ||
1337 | |||
1338 | byte[] buffer = new byte[msgLength]; | ||
1339 | |||
1340 | memory.Position = 0; | ||
1341 | using (GZipStream decompressor = new GZipStream(memory, CompressionMode.Decompress)) | ||
1342 | { | ||
1343 | decompressor.Read(buffer, 0, buffer.Length); | ||
1344 | } | ||
1345 | |||
1346 | return Util.UTF8.GetString(buffer); | ||
1347 | } | ||
1348 | } | ||
1349 | |||
1350 | /// <summary> | 1323 | /// <summary> |
1351 | /// Copy data from one stream to another, leaving the read position of both streams at the beginning. | 1324 | /// Copy data from one stream to another, leaving the read position of both streams at the beginning. |
1352 | /// </summary> | 1325 | /// </summary> |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index e614fd5..d683152 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -176,7 +176,8 @@ namespace OpenSim.Framework | |||
176 | 176 | ||
177 | public static void LogOutgoingDetail(string context, Stream outputStream) | 177 | public static void LogOutgoingDetail(string context, Stream outputStream) |
178 | { | 178 | { |
179 | using (StreamReader reader = new StreamReader(Util.Copy(outputStream), Encoding.UTF8)) | 179 | using (Stream stream = Util.Copy(outputStream)) |
180 | using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) | ||
180 | { | 181 | { |
181 | string output; | 182 | string output; |
182 | 183 | ||
@@ -262,12 +263,12 @@ namespace OpenSim.Framework | |||
262 | 263 | ||
263 | using (MemoryStream ms = new MemoryStream()) | 264 | using (MemoryStream ms = new MemoryStream()) |
264 | { | 265 | { |
265 | using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) | 266 | using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress, true)) |
266 | { | 267 | { |
267 | comp.Write(buffer, 0, buffer.Length); | 268 | comp.Write(buffer, 0, buffer.Length); |
268 | // We need to close the gzip stream before we write it anywhere | 269 | // We need to close the gzip stream before we write it anywhere |
269 | // because apparently something important related to gzip compression | 270 | // because apparently something important related to gzip compression |
270 | // gets written on the strteam upon Dispose() | 271 | // gets written on the stream upon Dispose() |
271 | } | 272 | } |
272 | byte[] buf = ms.ToArray(); | 273 | byte[] buf = ms.ToArray(); |
273 | request.ContentLength = buf.Length; //Count bytes to send | 274 | request.ContentLength = buf.Length; //Count bytes to send |
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 732781a..5cdcab9 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -231,7 +231,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
231 | { | 231 | { |
232 | try | 232 | try |
233 | { | 233 | { |
234 | List<int> layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(new MemoryStream(j2kData)); | 234 | List<int> layerStarts; |
235 | using (MemoryStream ms = new MemoryStream(j2kData)) | ||
236 | { | ||
237 | layerStarts = CSJ2K.J2kImage.GetLayerBoundaries(ms); | ||
238 | } | ||
235 | 239 | ||
236 | if (layerStarts != null && layerStarts.Count > 0) | 240 | if (layerStarts != null && layerStarts.Count > 0) |
237 | { | 241 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index ff87ece..13512a2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -289,18 +289,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends | |||
289 | 289 | ||
290 | rootElement.AppendChild(result); | 290 | rootElement.AppendChild(result); |
291 | 291 | ||
292 | return DocToBytes(doc); | 292 | return Util.DocToBytes(doc); |
293 | } | ||
294 | |||
295 | private byte[] DocToBytes(XmlDocument doc) | ||
296 | { | ||
297 | MemoryStream ms = new MemoryStream(); | ||
298 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
299 | xw.Formatting = Formatting.Indented; | ||
300 | doc.WriteTo(xw); | ||
301 | xw.Flush(); | ||
302 | |||
303 | return ms.ToArray(); | ||
304 | } | 293 | } |
305 | 294 | ||
306 | #endregion | 295 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index e9c6fb6..c8056d4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -918,17 +918,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
918 | { | 918 | { |
919 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); | 919 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); |
920 | 920 | ||
921 | MemoryStream ms = new MemoryStream(data); | 921 | using (MemoryStream ms = new MemoryStream(data)) |
922 | if (m_displacement != Vector3.Zero || m_rotation != 0f) | ||
923 | { | 922 | { |
924 | Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); | 923 | if (m_displacement != Vector3.Zero || m_rotation != 0f) |
925 | terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); | 924 | { |
926 | } | 925 | Vector2 rotationCenter = new Vector2(m_rotationCenter.X, m_rotationCenter.Y); |
927 | else | 926 | terrainModule.LoadFromStream(terrainPath, m_displacement, m_rotation, rotationCenter, ms); |
928 | { | 927 | } |
929 | terrainModule.LoadFromStream(terrainPath, ms); | 928 | else |
929 | { | ||
930 | terrainModule.LoadFromStream(terrainPath, ms); | ||
931 | } | ||
930 | } | 932 | } |
931 | ms.Close(); | ||
932 | 933 | ||
933 | m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); | 934 | m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); |
934 | 935 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 136a16e..448147a 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -569,10 +569,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
569 | string terrainPath = String.Format("{0}{1}{2}.r32", | 569 | string terrainPath = String.Format("{0}{1}{2}.r32", |
570 | regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName); | 570 | regionDir, ArchiveConstants.TERRAINS_PATH, scene.RegionInfo.RegionName); |
571 | 571 | ||
572 | MemoryStream ms = new MemoryStream(); | 572 | using (MemoryStream ms = new MemoryStream()) |
573 | scene.RequestModuleInterface<ITerrainModule>().SaveToStream(terrainPath, ms); | 573 | { |
574 | m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); | 574 | scene.RequestModuleInterface<ITerrainModule>().SaveToStream(terrainPath, ms); |
575 | ms.Close(); | 575 | m_archiveWriter.WriteFile(terrainPath, ms.ToArray()); |
576 | } | ||
576 | 577 | ||
577 | m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); | 578 | m_log.InfoFormat("[ARCHIVER]: Adding scene objects to archive."); |
578 | 579 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index eecc478..b417198 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -1116,9 +1116,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1116 | { | 1116 | { |
1117 | try | 1117 | try |
1118 | { | 1118 | { |
1119 | MemoryStream terrainStream = new MemoryStream(terrainData); | 1119 | using (MemoryStream terrainStream = new MemoryStream(terrainData)) |
1120 | terr.LoadFromStream(filename, terrainStream); | 1120 | terr.LoadFromStream(filename, terrainStream); |
1121 | terrainStream.Close(); | ||
1122 | 1121 | ||
1123 | FileInfo x = new FileInfo(filename); | 1122 | FileInfo x = new FileInfo(filename); |
1124 | remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear."); | 1123 | remoteClient.SendAlertMessage("Your terrain was loaded as a " + x.Extension + " file. It may take a few moments to appear."); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs index 2366767..ec5af2b 100644 --- a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs | |||
@@ -281,18 +281,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
281 | 281 | ||
282 | rootElement.AppendChild(result); | 282 | rootElement.AppendChild(result); |
283 | 283 | ||
284 | return DocToBytes(doc); | 284 | return Util.DocToBytes(doc); |
285 | } | 285 | } |
286 | 286 | ||
287 | private byte[] DocToBytes(XmlDocument doc) | ||
288 | { | ||
289 | MemoryStream ms = new MemoryStream(); | ||
290 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
291 | xw.Formatting = Formatting.Indented; | ||
292 | doc.WriteTo(xw); | ||
293 | xw.Flush(); | ||
294 | |||
295 | return ms.ToArray(); | ||
296 | } | ||
297 | } | 287 | } |
298 | } | 288 | } |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs index 328fbf0..65f464a 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs | |||
@@ -54,13 +54,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
54 | { | 54 | { |
55 | string xmlstream = GetObjectXml(scene); | 55 | string xmlstream = GetObjectXml(scene); |
56 | 56 | ||
57 | MemoryStream stream = ReformatXmlString(xmlstream); | 57 | using (MemoryStream stream = ReformatXmlString(xmlstream)) |
58 | 58 | { | |
59 | stream.Seek(0, SeekOrigin.Begin); | 59 | stream.Seek(0, SeekOrigin.Begin); |
60 | CreateXmlFile(stream, fileName); | 60 | CreateXmlFile(stream, fileName); |
61 | 61 | ||
62 | stream.Seek(0, SeekOrigin.Begin); | 62 | stream.Seek(0, SeekOrigin.Begin); |
63 | CreateCompressedXmlFile(stream, fileName); | 63 | CreateCompressedXmlFile(stream, fileName); |
64 | } | ||
64 | } | 65 | } |
65 | 66 | ||
66 | private static MemoryStream ReformatXmlString(string xmlstream) | 67 | private static MemoryStream ReformatXmlString(string xmlstream) |
@@ -112,13 +113,16 @@ namespace OpenSim.Region.CoreModules.World.Serialiser | |||
112 | { | 113 | { |
113 | #region GZip Compressed Version | 114 | #region GZip Compressed Version |
114 | 115 | ||
115 | FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); | 116 | using (FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create)) |
116 | MemoryStream gzipMSStream = new MemoryStream(); | 117 | using (MemoryStream gzipMSStream = new MemoryStream()) |
117 | GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); | 118 | { |
118 | xmlStream.WriteTo(gzipStream); | 119 | using (GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress, true)) |
119 | gzipMSStream.WriteTo(objectsFileCompressed); | 120 | { |
120 | objectsFileCompressed.Flush(); | 121 | xmlStream.WriteTo(gzipStream); |
121 | objectsFileCompressed.Close(); | 122 | } |
123 | |||
124 | gzipMSStream.WriteTo(objectsFileCompressed); | ||
125 | } | ||
122 | 126 | ||
123 | #endregion | 127 | #endregion |
124 | } | 128 | } |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 2d28d6e..995e297 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -1145,7 +1145,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1145 | 1145 | ||
1146 | if (myMapImageJPEG.Length == 0) | 1146 | if (myMapImageJPEG.Length == 0) |
1147 | { | 1147 | { |
1148 | MemoryStream imgstream = new MemoryStream(); | 1148 | MemoryStream imgstream = null; |
1149 | Bitmap mapTexture = new Bitmap(1,1); | 1149 | Bitmap mapTexture = new Bitmap(1,1); |
1150 | ManagedImage managedImage; | 1150 | ManagedImage managedImage; |
1151 | Image image = (Image)mapTexture; | 1151 | Image image = (Image)mapTexture; |
@@ -1192,10 +1192,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1192 | image.Dispose(); | 1192 | image.Dispose(); |
1193 | 1193 | ||
1194 | if (imgstream != null) | 1194 | if (imgstream != null) |
1195 | { | ||
1196 | imgstream.Close(); | ||
1197 | imgstream.Dispose(); | 1195 | imgstream.Dispose(); |
1198 | } | ||
1199 | } | 1196 | } |
1200 | } | 1197 | } |
1201 | else | 1198 | else |
@@ -1639,4 +1636,4 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1639 | public uint itemtype; | 1636 | public uint itemtype; |
1640 | public ulong regionhandle; | 1637 | public ulong regionhandle; |
1641 | } | 1638 | } |
1642 | } \ No newline at end of file | 1639 | } |
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 4a06f6e..33899aa 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | |||
@@ -373,24 +373,27 @@ namespace OpenSim.Region.DataSnapshot | |||
373 | for (int i = 0; i < services.Length; i++) | 373 | for (int i = 0; i < services.Length; i++) |
374 | { | 374 | { |
375 | string url = services[i].Trim(); | 375 | string url = services[i].Trim(); |
376 | RestClient cli = new RestClient(url); | 376 | using (RestClient cli = new RestClient(url)) |
377 | cli.AddQueryParameter("service", serviceName); | ||
378 | cli.AddQueryParameter("host", m_hostname); | ||
379 | cli.AddQueryParameter("port", m_listener_port); | ||
380 | cli.AddQueryParameter("secret", m_Secret.ToString()); | ||
381 | cli.RequestMethod = "GET"; | ||
382 | try | ||
383 | { | ||
384 | reply = cli.Request(null); | ||
385 | } | ||
386 | catch (WebException) | ||
387 | { | 377 | { |
388 | m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); | 378 | cli.AddQueryParameter("service", serviceName); |
389 | } | 379 | cli.AddQueryParameter("host", m_hostname); |
390 | catch (Exception e) | 380 | cli.AddQueryParameter("port", m_listener_port); |
391 | { | 381 | cli.AddQueryParameter("secret", m_Secret.ToString()); |
392 | m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); | 382 | cli.RequestMethod = "GET"; |
383 | try | ||
384 | { | ||
385 | reply = cli.Request(null); | ||
386 | } | ||
387 | catch (WebException) | ||
388 | { | ||
389 | m_log.Warn("[DATASNAPSHOT]: Unable to notify " + url); | ||
390 | } | ||
391 | catch (Exception e) | ||
392 | { | ||
393 | m_log.Warn("[DATASNAPSHOT]: Ignoring unknown exception " + e.ToString()); | ||
394 | } | ||
393 | } | 395 | } |
396 | |||
394 | byte[] response = new byte[1024]; | 397 | byte[] response = new byte[1024]; |
395 | // int n = 0; | 398 | // int n = 0; |
396 | try | 399 | try |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs index 3afc87f..b3b38b2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -113,31 +113,34 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
113 | 113 | ||
114 | public byte[] ToBytes() | 114 | public byte[] ToBytes() |
115 | { | 115 | { |
116 | byte[] outputbytes = new byte[0]; | 116 | byte[] outputbytes; |
117 | 117 | ||
118 | BinaryWriter iostream = new BinaryWriter(new MemoryStream()); | 118 | using (MemoryStream ms = new MemoryStream()) |
119 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0))); | 119 | using (BinaryWriter iostream = new BinaryWriter(ms)) |
120 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1))); | ||
121 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority))); | ||
122 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length))); | ||
123 | iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName)); | ||
124 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint))); | ||
125 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint))); | ||
126 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0))); | ||
127 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime))); | ||
128 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime))); | ||
129 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose))); | ||
130 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length)))); | ||
131 | |||
132 | for (int i = 0; i < Joints.Length; i++) | ||
133 | { | 120 | { |
134 | Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint); | 121 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0))); |
122 | iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1))); | ||
123 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority))); | ||
124 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length))); | ||
125 | iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName)); | ||
126 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint))); | ||
127 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint))); | ||
128 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0))); | ||
129 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime))); | ||
130 | iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime))); | ||
131 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose))); | ||
132 | iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length)))); | ||
133 | |||
134 | for (int i = 0; i < Joints.Length; i++) | ||
135 | { | ||
136 | Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint); | ||
137 | } | ||
138 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0))); | ||
139 | |||
140 | using (MemoryStream ms2 = (MemoryStream)iostream.BaseStream) | ||
141 | outputbytes = ms2.ToArray(); | ||
135 | } | 142 | } |
136 | iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0))); | 143 | |
137 | MemoryStream ms = (MemoryStream)iostream.BaseStream; | ||
138 | outputbytes = ms.ToArray(); | ||
139 | ms.Close(); | ||
140 | iostream.Close(); | ||
141 | return outputbytes; | 144 | return outputbytes; |
142 | } | 145 | } |
143 | 146 | ||
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 2d489ea..b4a171f 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -280,7 +280,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
280 | if (!m_selected) | 280 | if (!m_selected) |
281 | { | 281 | { |
282 | StopTimer(); | 282 | StopTimer(); |
283 | m_serializedPosition = m_group.AbsolutePosition; | 283 | m_serializedPosition = m_group.AbsolutePosition; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
@@ -308,10 +308,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
308 | 308 | ||
309 | try | 309 | try |
310 | { | 310 | { |
311 | MemoryStream ms = new MemoryStream(data); | 311 | using (MemoryStream ms = new MemoryStream(data)) |
312 | BinaryFormatter fmt = new BinaryFormatter(); | 312 | { |
313 | 313 | BinaryFormatter fmt = new BinaryFormatter(); | |
314 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); | 314 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); |
315 | } | ||
315 | 316 | ||
316 | newMotion.m_group = grp; | 317 | newMotion.m_group = grp; |
317 | 318 | ||
@@ -345,26 +346,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
345 | return; | 346 | return; |
346 | 347 | ||
347 | m_group = grp; | 348 | m_group = grp; |
348 | m_scene = grp.Scene; | 349 | m_scene = grp.Scene; |
349 | 350 | ||
350 | Vector3 grppos = grp.AbsolutePosition; | 351 | Vector3 grppos = grp.AbsolutePosition; |
351 | Vector3 offset = grppos - m_serializedPosition; | 352 | Vector3 offset = grppos - m_serializedPosition; |
352 | // avoid doing it more than once | 353 | // avoid doing it more than once |
353 | // current this will happen dragging a prim to other region | 354 | // current this will happen dragging a prim to other region |
354 | m_serializedPosition = grppos; | 355 | m_serializedPosition = grppos; |
355 | 356 | ||
356 | m_basePosition += offset; | 357 | m_basePosition += offset; |
357 | m_nextPosition += offset; | 358 | m_nextPosition += offset; |
358 | 359 | ||
359 | m_currentFrame.StartPosition += offset; | 360 | m_currentFrame.StartPosition += offset; |
360 | m_currentFrame.Position += offset; | 361 | m_currentFrame.Position += offset; |
361 | 362 | ||
362 | for (int i = 0; i < m_frames.Count; i++) | 363 | for (int i = 0; i < m_frames.Count; i++) |
363 | { | 364 | { |
364 | Keyframe k = m_frames[i]; | 365 | Keyframe k = m_frames[i]; |
365 | k.StartPosition += offset; | 366 | k.StartPosition += offset; |
366 | k.Position += offset; | 367 | k.Position += offset; |
367 | m_frames[i]=k; | 368 | m_frames[i]=k; |
368 | } | 369 | } |
369 | 370 | ||
370 | if (m_running) | 371 | if (m_running) |
@@ -527,7 +528,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
527 | { | 528 | { |
528 | k.Position = pos; | 529 | k.Position = pos; |
529 | // k.Velocity = Vector3.Zero; | 530 | // k.Velocity = Vector3.Zero; |
530 | } | 531 | } |
531 | 532 | ||
532 | k.StartRotation = rot; | 533 | k.StartRotation = rot; |
533 | if (k.Rotation.HasValue) | 534 | if (k.Rotation.HasValue) |
@@ -764,19 +765,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | public Byte[] Serialize() | 765 | public Byte[] Serialize() |
765 | { | 766 | { |
766 | StopTimer(); | 767 | StopTimer(); |
767 | MemoryStream ms = new MemoryStream(); | ||
768 | 768 | ||
769 | BinaryFormatter fmt = new BinaryFormatter(); | ||
770 | SceneObjectGroup tmp = m_group; | 769 | SceneObjectGroup tmp = m_group; |
771 | m_group = null; | 770 | m_group = null; |
772 | if (!m_selected && tmp != null) | 771 | if (!m_selected && tmp != null) |
773 | m_serializedPosition = tmp.AbsolutePosition; | 772 | m_serializedPosition = tmp.AbsolutePosition; |
774 | fmt.Serialize(ms, this); | 773 | |
775 | m_group = tmp; | 774 | using (MemoryStream ms = new MemoryStream()) |
776 | if (m_running && !m_waitingCrossing) | 775 | { |
777 | StartTimer(); | 776 | BinaryFormatter fmt = new BinaryFormatter(); |
777 | fmt.Serialize(ms, this); | ||
778 | m_group = tmp; | ||
779 | if (m_running && !m_waitingCrossing) | ||
780 | StartTimer(); | ||
778 | 781 | ||
779 | return ms.ToArray(); | 782 | return ms.ToArray(); |
783 | } | ||
780 | } | 784 | } |
781 | 785 | ||
782 | public void StartCrossingCheck() | 786 | public void StartCrossingCheck() |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index a7015e1..d07cc6a 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -458,35 +458,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | if (null == assetBase) | 458 | if (null == assetBase) |
459 | return; | 459 | return; |
460 | 460 | ||
461 | MemoryStream ms = new MemoryStream(assetBase.Data); | 461 | using (MemoryStream ms = new MemoryStream(assetBase.Data)) |
462 | StreamReader sr = new StreamReader(ms); | 462 | using (StreamReader sr = new StreamReader(ms)) |
463 | |||
464 | sr.ReadLine(); // Unknown (Version?) | ||
465 | sr.ReadLine(); // Unknown | ||
466 | sr.ReadLine(); // Unknown | ||
467 | sr.ReadLine(); // Name | ||
468 | sr.ReadLine(); // Comment ? | ||
469 | int count = Convert.ToInt32(sr.ReadLine()); // Item count | ||
470 | |||
471 | for (int i = 0 ; i < count ; i++) | ||
472 | { | 463 | { |
473 | string type = sr.ReadLine(); | 464 | sr.ReadLine(); // Unknown (Version?) |
474 | if (type == null) | 465 | sr.ReadLine(); // Unknown |
475 | break; | 466 | sr.ReadLine(); // Unknown |
476 | string name = sr.ReadLine(); | 467 | sr.ReadLine(); // Name |
477 | if (name == null) | 468 | sr.ReadLine(); // Comment ? |
478 | break; | 469 | int count = Convert.ToInt32(sr.ReadLine()); // Item count |
479 | string id = sr.ReadLine(); | 470 | |
480 | if (id == null) | 471 | for (int i = 0 ; i < count ; i++) |
481 | break; | 472 | { |
482 | string unknown = sr.ReadLine(); | 473 | string type = sr.ReadLine(); |
483 | if (unknown == null) | 474 | if (type == null) |
484 | break; | 475 | break; |
485 | 476 | string name = sr.ReadLine(); | |
486 | // If it can be parsed as a UUID, it is an asset ID | 477 | if (name == null) |
487 | UUID uuid; | 478 | break; |
488 | if (UUID.TryParse(id, out uuid)) | 479 | string id = sr.ReadLine(); |
489 | assetUuids[uuid] = (sbyte)AssetType.Animation; | 480 | if (id == null) |
481 | break; | ||
482 | string unknown = sr.ReadLine(); | ||
483 | if (unknown == null) | ||
484 | break; | ||
485 | |||
486 | // If it can be parsed as a UUID, it is an asset ID | ||
487 | UUID uuid; | ||
488 | if (UUID.TryParse(id, out uuid)) | ||
489 | assetUuids[uuid] = (sbyte)AssetType.Animation; // the asset is either an Animation or a Sound, but this distinction isn't important | ||
490 | } | ||
490 | } | 491 | } |
491 | } | 492 | } |
492 | 493 | ||
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index c92e23c..8f1d56b 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -196,17 +196,19 @@ namespace OpenSim.Server.Base | |||
196 | 196 | ||
197 | public static byte[] SerializeResult(XmlSerializer xs, object data) | 197 | public static byte[] SerializeResult(XmlSerializer xs, object data) |
198 | { | 198 | { |
199 | MemoryStream ms = new MemoryStream(); | 199 | using (MemoryStream ms = new MemoryStream()) |
200 | XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8); | 200 | using (XmlTextWriter xw = new XmlTextWriter(ms, Util.UTF8)) |
201 | xw.Formatting = Formatting.Indented; | 201 | { |
202 | xs.Serialize(xw, data); | 202 | xw.Formatting = Formatting.Indented; |
203 | xw.Flush(); | 203 | xs.Serialize(xw, data); |
204 | xw.Flush(); | ||
204 | 205 | ||
205 | ms.Seek(0, SeekOrigin.Begin); | 206 | ms.Seek(0, SeekOrigin.Begin); |
206 | byte[] ret = ms.GetBuffer(); | 207 | byte[] ret = ms.GetBuffer(); |
207 | Array.Resize(ref ret, (int)ms.Length); | 208 | Array.Resize(ref ret, (int)ms.Length); |
208 | 209 | ||
209 | return ret; | 210 | return ret; |
211 | } | ||
210 | } | 212 | } |
211 | 213 | ||
212 | /// <summary> | 214 | /// <summary> |
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs index 5d65f67..6ee98b3 100644 --- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs | |||
@@ -209,7 +209,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
209 | 209 | ||
210 | rootElement.AppendChild(result); | 210 | rootElement.AppendChild(result); |
211 | 211 | ||
212 | return DocToBytes(doc); | 212 | return Util.DocToBytes(doc); |
213 | } | 213 | } |
214 | 214 | ||
215 | byte[] GetAuthInfo(UUID principalID) | 215 | byte[] GetAuthInfo(UUID principalID) |
@@ -279,7 +279,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
279 | 279 | ||
280 | rootElement.AppendChild(result); | 280 | rootElement.AppendChild(result); |
281 | 281 | ||
282 | return DocToBytes(doc); | 282 | return Util.DocToBytes(doc); |
283 | } | 283 | } |
284 | 284 | ||
285 | private byte[] SuccessResult(string token) | 285 | private byte[] SuccessResult(string token) |
@@ -306,18 +306,7 @@ namespace OpenSim.Server.Handlers.Authentication | |||
306 | 306 | ||
307 | rootElement.AppendChild(t); | 307 | rootElement.AppendChild(t); |
308 | 308 | ||
309 | return DocToBytes(doc); | 309 | return Util.DocToBytes(doc); |
310 | } | ||
311 | |||
312 | private byte[] DocToBytes(XmlDocument doc) | ||
313 | { | ||
314 | MemoryStream ms = new MemoryStream(); | ||
315 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
316 | xw.Formatting = Formatting.Indented; | ||
317 | doc.WriteTo(xw); | ||
318 | xw.Flush(); | ||
319 | |||
320 | return ms.GetBuffer(); | ||
321 | } | 310 | } |
322 | 311 | ||
323 | private byte[] ResultToBytes(Dictionary<string, object> result) | 312 | private byte[] ResultToBytes(Dictionary<string, object> result) |
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index 59dbed4..ff8699f 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | |||
@@ -247,7 +247,7 @@ namespace OpenSim.Server.Handlers.Avatar | |||
247 | 247 | ||
248 | rootElement.AppendChild(result); | 248 | rootElement.AppendChild(result); |
249 | 249 | ||
250 | return DocToBytes(doc); | 250 | return Util.DocToBytes(doc); |
251 | } | 251 | } |
252 | 252 | ||
253 | private byte[] FailureResult() | 253 | private byte[] FailureResult() |
@@ -269,18 +269,7 @@ namespace OpenSim.Server.Handlers.Avatar | |||
269 | 269 | ||
270 | rootElement.AppendChild(result); | 270 | rootElement.AppendChild(result); |
271 | 271 | ||
272 | return DocToBytes(doc); | 272 | return Util.DocToBytes(doc); |
273 | } | ||
274 | |||
275 | private byte[] DocToBytes(XmlDocument doc) | ||
276 | { | ||
277 | MemoryStream ms = new MemoryStream(); | ||
278 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
279 | xw.Formatting = Formatting.Indented; | ||
280 | doc.WriteTo(xw); | ||
281 | xw.Flush(); | ||
282 | |||
283 | return ms.ToArray(); | ||
284 | } | 273 | } |
285 | 274 | ||
286 | } | 275 | } |
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index d442443..3aab30b 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |||
@@ -229,7 +229,7 @@ namespace OpenSim.Server.Handlers.Friends | |||
229 | 229 | ||
230 | rootElement.AppendChild(result); | 230 | rootElement.AppendChild(result); |
231 | 231 | ||
232 | return DocToBytes(doc); | 232 | return Util.DocToBytes(doc); |
233 | } | 233 | } |
234 | 234 | ||
235 | private byte[] FailureResult() | 235 | private byte[] FailureResult() |
@@ -261,18 +261,7 @@ namespace OpenSim.Server.Handlers.Friends | |||
261 | 261 | ||
262 | rootElement.AppendChild(message); | 262 | rootElement.AppendChild(message); |
263 | 263 | ||
264 | return DocToBytes(doc); | 264 | return Util.DocToBytes(doc); |
265 | } | ||
266 | |||
267 | private byte[] DocToBytes(XmlDocument doc) | ||
268 | { | ||
269 | MemoryStream ms = new MemoryStream(); | ||
270 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
271 | xw.Formatting = Formatting.Indented; | ||
272 | doc.WriteTo(xw); | ||
273 | xw.Flush(); | ||
274 | |||
275 | return ms.ToArray(); | ||
276 | } | 265 | } |
277 | 266 | ||
278 | void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags) | 267 | void FromKeyValuePairs(Dictionary<string, object> kvp, out string principalID, out string friend, out int flags) |
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs index dda4756..d5a9d67 100644 --- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs | |||
@@ -602,7 +602,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
602 | 602 | ||
603 | rootElement.AppendChild(result); | 603 | rootElement.AppendChild(result); |
604 | 604 | ||
605 | return DocToBytes(doc); | 605 | return Util.DocToBytes(doc); |
606 | } | 606 | } |
607 | 607 | ||
608 | private byte[] FailureResult() | 608 | private byte[] FailureResult() |
@@ -634,18 +634,7 @@ namespace OpenSim.Server.Handlers.Grid | |||
634 | 634 | ||
635 | rootElement.AppendChild(message); | 635 | rootElement.AppendChild(message); |
636 | 636 | ||
637 | return DocToBytes(doc); | 637 | return Util.DocToBytes(doc); |
638 | } | ||
639 | |||
640 | private byte[] DocToBytes(XmlDocument doc) | ||
641 | { | ||
642 | MemoryStream ms = new MemoryStream(); | ||
643 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
644 | xw.Formatting = Formatting.Indented; | ||
645 | doc.WriteTo(xw); | ||
646 | xw.Flush(); | ||
647 | |||
648 | return ms.ToArray(); | ||
649 | } | 638 | } |
650 | 639 | ||
651 | #endregion | 640 | #endregion |
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs index 006f6ab..9237c63 100644 --- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs | |||
@@ -279,7 +279,7 @@ namespace OpenSim.Server.Handlers.GridUser | |||
279 | 279 | ||
280 | rootElement.AppendChild(result); | 280 | rootElement.AppendChild(result); |
281 | 281 | ||
282 | return DocToBytes(doc); | 282 | return Util.DocToBytes(doc); |
283 | } | 283 | } |
284 | 284 | ||
285 | private byte[] FailureResult() | 285 | private byte[] FailureResult() |
@@ -301,20 +301,8 @@ namespace OpenSim.Server.Handlers.GridUser | |||
301 | 301 | ||
302 | rootElement.AppendChild(result); | 302 | rootElement.AppendChild(result); |
303 | 303 | ||
304 | return DocToBytes(doc); | 304 | return Util.DocToBytes(doc); |
305 | } | 305 | } |
306 | 306 | ||
307 | private byte[] DocToBytes(XmlDocument doc) | ||
308 | { | ||
309 | MemoryStream ms = new MemoryStream(); | ||
310 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
311 | xw.Formatting = Formatting.Indented; | ||
312 | doc.WriteTo(xw); | ||
313 | xw.Flush(); | ||
314 | |||
315 | return ms.ToArray(); | ||
316 | } | ||
317 | |||
318 | |||
319 | } | 307 | } |
320 | } | 308 | } |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index a2bdadb..37b47ed 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | |||
@@ -335,7 +335,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
335 | 335 | ||
336 | rootElement.AppendChild(result); | 336 | rootElement.AppendChild(result); |
337 | 337 | ||
338 | return DocToBytes(doc); | 338 | return Util.DocToBytes(doc); |
339 | } | 339 | } |
340 | 340 | ||
341 | private byte[] SuccessResult(string value) | 341 | private byte[] SuccessResult(string value) |
@@ -362,7 +362,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
362 | 362 | ||
363 | rootElement.AppendChild(message); | 363 | rootElement.AppendChild(message); |
364 | 364 | ||
365 | return DocToBytes(doc); | 365 | return Util.DocToBytes(doc); |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
@@ -395,7 +395,7 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
395 | 395 | ||
396 | rootElement.AppendChild(message); | 396 | rootElement.AppendChild(message); |
397 | 397 | ||
398 | return DocToBytes(doc); | 398 | return Util.DocToBytes(doc); |
399 | } | 399 | } |
400 | 400 | ||
401 | private byte[] BoolResult(bool value) | 401 | private byte[] BoolResult(bool value) |
@@ -417,21 +417,9 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
417 | 417 | ||
418 | rootElement.AppendChild(result); | 418 | rootElement.AppendChild(result); |
419 | 419 | ||
420 | return DocToBytes(doc); | 420 | return Util.DocToBytes(doc); |
421 | } | 421 | } |
422 | 422 | ||
423 | private byte[] DocToBytes(XmlDocument doc) | ||
424 | { | ||
425 | MemoryStream ms = new MemoryStream(); | ||
426 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
427 | xw.Formatting = Formatting.Indented; | ||
428 | doc.WriteTo(xw); | ||
429 | xw.Flush(); | ||
430 | |||
431 | return ms.ToArray(); | ||
432 | } | ||
433 | |||
434 | |||
435 | #endregion | 423 | #endregion |
436 | } | 424 | } |
437 | } | 425 | } |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 7283237..0288fa6 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -191,18 +191,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
191 | 191 | ||
192 | rootElement.AppendChild(result); | 192 | rootElement.AppendChild(result); |
193 | 193 | ||
194 | return DocToBytes(doc); | 194 | return Util.DocToBytes(doc); |
195 | } | ||
196 | |||
197 | private byte[] DocToBytes(XmlDocument doc) | ||
198 | { | ||
199 | MemoryStream ms = new MemoryStream(); | ||
200 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
201 | xw.Formatting = Formatting.Indented; | ||
202 | doc.WriteTo(xw); | ||
203 | xw.Flush(); | ||
204 | |||
205 | return ms.ToArray(); | ||
206 | } | 195 | } |
207 | 196 | ||
208 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) | 197 | byte[] HandleCreateUserInventory(Dictionary<string,object> request) |
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs index a896fdb..649a27e 100644 --- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs +++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs | |||
@@ -188,7 +188,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
188 | 188 | ||
189 | rootElement.AppendChild(result); | 189 | rootElement.AppendChild(result); |
190 | 190 | ||
191 | return DocToBytes(doc); | 191 | return Util.DocToBytes(doc); |
192 | } | 192 | } |
193 | 193 | ||
194 | private byte[] FailureResult(string msg) | 194 | private byte[] FailureResult(string msg) |
@@ -215,18 +215,7 @@ namespace OpenSim.Server.Handlers.MapImage | |||
215 | 215 | ||
216 | rootElement.AppendChild(message); | 216 | rootElement.AppendChild(message); |
217 | 217 | ||
218 | return DocToBytes(doc); | 218 | return Util.DocToBytes(doc); |
219 | } | ||
220 | |||
221 | private byte[] DocToBytes(XmlDocument doc) | ||
222 | { | ||
223 | MemoryStream ms = new MemoryStream(); | ||
224 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
225 | xw.Formatting = Formatting.Indented; | ||
226 | doc.WriteTo(xw); | ||
227 | xw.Flush(); | ||
228 | |||
229 | return ms.ToArray(); | ||
230 | } | 219 | } |
231 | 220 | ||
232 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) | 221 | private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) |
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 0b3b961..49dbcb5 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | |||
@@ -265,7 +265,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
265 | 265 | ||
266 | rootElement.AppendChild(result); | 266 | rootElement.AppendChild(result); |
267 | 267 | ||
268 | return DocToBytes(doc); | 268 | return Util.DocToBytes(doc); |
269 | } | 269 | } |
270 | 270 | ||
271 | private byte[] FailureResult() | 271 | private byte[] FailureResult() |
@@ -287,18 +287,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
287 | 287 | ||
288 | rootElement.AppendChild(result); | 288 | rootElement.AppendChild(result); |
289 | 289 | ||
290 | return DocToBytes(doc); | 290 | return Util.DocToBytes(doc); |
291 | } | ||
292 | |||
293 | private byte[] DocToBytes(XmlDocument doc) | ||
294 | { | ||
295 | MemoryStream ms = new MemoryStream(); | ||
296 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
297 | xw.Formatting = Formatting.Indented; | ||
298 | doc.WriteTo(xw); | ||
299 | xw.Flush(); | ||
300 | |||
301 | return ms.ToArray(); | ||
302 | } | 291 | } |
303 | 292 | ||
304 | } | 293 | } |
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index 6d3a3a7..da2bfeb 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | |||
@@ -250,14 +250,30 @@ namespace OpenSim.Server.Handlers.Simulation | |||
250 | return encoding.GetBytes("false"); | 250 | return encoding.GetBytes("false"); |
251 | } | 251 | } |
252 | 252 | ||
253 | string requestBody; | ||
254 | |||
253 | Stream inputStream = request; | 255 | Stream inputStream = request; |
254 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | 256 | Stream innerStream = null; |
255 | inputStream = new GZipStream(inputStream, CompressionMode.Decompress); | 257 | try |
258 | { | ||
259 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
260 | { | ||
261 | innerStream = inputStream; | ||
262 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
263 | } | ||
256 | 264 | ||
257 | StreamReader reader = new StreamReader(inputStream, encoding); | 265 | using (StreamReader reader = new StreamReader(inputStream, encoding)) |
266 | { | ||
267 | requestBody = reader.ReadToEnd(); | ||
268 | } | ||
269 | } | ||
270 | finally | ||
271 | { | ||
272 | if (innerStream != null) | ||
273 | innerStream.Dispose(); | ||
274 | inputStream.Dispose(); | ||
275 | } | ||
258 | 276 | ||
259 | string requestBody = reader.ReadToEnd(); | ||
260 | reader.Close(); | ||
261 | keysvals.Add("body", requestBody); | 277 | keysvals.Add("body", requestBody); |
262 | 278 | ||
263 | Hashtable responsedata = new Hashtable(); | 279 | Hashtable responsedata = new Hashtable(); |
@@ -461,15 +477,31 @@ namespace OpenSim.Server.Handlers.Simulation | |||
461 | keysvals.Add("headers", headervals); | 477 | keysvals.Add("headers", headervals); |
462 | keysvals.Add("querystringkeys", querystringkeys); | 478 | keysvals.Add("querystringkeys", querystringkeys); |
463 | 479 | ||
480 | String requestBody; | ||
481 | Encoding encoding = Encoding.UTF8; | ||
482 | |||
464 | Stream inputStream = request; | 483 | Stream inputStream = request; |
465 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | 484 | Stream innerStream = null; |
466 | inputStream = new GZipStream(inputStream, CompressionMode.Decompress); | 485 | try |
486 | { | ||
487 | if ((httpRequest.ContentType == "application/x-gzip" || httpRequest.Headers["Content-Encoding"] == "gzip") || (httpRequest.Headers["X-Content-Encoding"] == "gzip")) | ||
488 | { | ||
489 | innerStream = inputStream; | ||
490 | inputStream = new GZipStream(innerStream, CompressionMode.Decompress); | ||
491 | } | ||
467 | 492 | ||
468 | Encoding encoding = Encoding.UTF8; | 493 | using (StreamReader reader = new StreamReader(inputStream, encoding)) |
469 | StreamReader reader = new StreamReader(inputStream, encoding); | 494 | { |
495 | requestBody = reader.ReadToEnd(); | ||
496 | } | ||
497 | } | ||
498 | finally | ||
499 | { | ||
500 | if (innerStream != null) | ||
501 | innerStream.Dispose(); | ||
502 | inputStream.Dispose(); | ||
503 | } | ||
470 | 504 | ||
471 | string requestBody = reader.ReadToEnd(); | ||
472 | reader.Close(); | ||
473 | keysvals.Add("body", requestBody); | 505 | keysvals.Add("body", requestBody); |
474 | 506 | ||
475 | httpResponse.StatusCode = 200; | 507 | httpResponse.StatusCode = 200; |
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs index c87e022..a77d78e 100644 --- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs +++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs | |||
@@ -315,7 +315,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
315 | 315 | ||
316 | rootElement.AppendChild(result); | 316 | rootElement.AppendChild(result); |
317 | 317 | ||
318 | return DocToBytes(doc); | 318 | return Util.DocToBytes(doc); |
319 | } | 319 | } |
320 | 320 | ||
321 | private byte[] FailureResult() | 321 | private byte[] FailureResult() |
@@ -337,18 +337,7 @@ namespace OpenSim.Server.Handlers.UserAccounts | |||
337 | 337 | ||
338 | rootElement.AppendChild(result); | 338 | rootElement.AppendChild(result); |
339 | 339 | ||
340 | return DocToBytes(doc); | 340 | return Util.DocToBytes(doc); |
341 | } | ||
342 | |||
343 | private byte[] DocToBytes(XmlDocument doc) | ||
344 | { | ||
345 | MemoryStream ms = new MemoryStream(); | ||
346 | XmlTextWriter xw = new XmlTextWriter(ms, null); | ||
347 | xw.Formatting = Formatting.Indented; | ||
348 | doc.WriteTo(xw); | ||
349 | xw.Flush(); | ||
350 | |||
351 | return ms.ToArray(); | ||
352 | } | 341 | } |
353 | 342 | ||
354 | private byte[] ResultToBytes(Dictionary<string, object> result) | 343 | private byte[] ResultToBytes(Dictionary<string, object> result) |
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index 0996acb..badacb7 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs | |||
@@ -171,27 +171,29 @@ namespace OpenSim.Services.Connectors | |||
171 | return fullAsset.Data; | 171 | return fullAsset.Data; |
172 | } | 172 | } |
173 | 173 | ||
174 | RestClient rc = new RestClient(m_ServerURI); | 174 | using (RestClient rc = new RestClient(m_ServerURI)) |
175 | rc.AddResourcePath("assets"); | 175 | { |
176 | rc.AddResourcePath(id); | 176 | rc.AddResourcePath("assets"); |
177 | rc.AddResourcePath("data"); | 177 | rc.AddResourcePath(id); |
178 | rc.AddResourcePath("data"); | ||
178 | 179 | ||
179 | rc.RequestMethod = "GET"; | 180 | rc.RequestMethod = "GET"; |
180 | 181 | ||
181 | Stream s = rc.Request(m_Auth); | 182 | Stream s = rc.Request(m_Auth); |
182 | 183 | ||
183 | if (s == null) | 184 | if (s == null) |
184 | return null; | 185 | return null; |
185 | 186 | ||
186 | if (s.Length > 0) | 187 | if (s.Length > 0) |
187 | { | 188 | { |
188 | byte[] ret = new byte[s.Length]; | 189 | byte[] ret = new byte[s.Length]; |
189 | s.Read(ret, 0, (int)s.Length); | 190 | s.Read(ret, 0, (int)s.Length); |
190 | 191 | ||
191 | return ret; | 192 | return ret; |
192 | } | 193 | } |
193 | 194 | ||
194 | return null; | 195 | return null; |
196 | } | ||
195 | } | 197 | } |
196 | 198 | ||
197 | public bool Get(string id, Object sender, AssetRetrieved handler) | 199 | public bool Get(string id, Object sender, AssetRetrieved handler) |