aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorMelanie2009-10-05 10:17:23 +0100
committerMelanie2009-10-05 10:17:23 +0100
commit0744292b479446eb1ebec828afafacc0189709ca (patch)
tree3c43b5f425aff61d3625b75b7aef35ce5062ae56 /OpenSim/Framework
parentMerge branch 'master' into vehicles (diff)
parentMake the asset connector async Get overload return false if the asset (diff)
downloadopensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.zip
opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.gz
opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.bz2
opensim-SC_OLD-0744292b479446eb1ebec828afafacc0189709ca.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AssetLandmark.cs2
-rw-r--r--OpenSim/Framework/Capabilities/LLSD.cs4
-rw-r--r--OpenSim/Framework/Capabilities/LLSDStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Communications/Clients/RegionClient.cs31
-rw-r--r--OpenSim/Framework/Communications/XMPP/XmppWriter.cs2
-rw-r--r--OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs30
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestSessionService.cs20
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs34
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs23
-rw-r--r--OpenSim/Framework/Util.cs10
12 files changed, 129 insertions, 33 deletions
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs
index 7c87c34..fd7a2cd 100644
--- a/OpenSim/Framework/AssetLandmark.cs
+++ b/OpenSim/Framework/AssetLandmark.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Framework
49 49
50 private void InternData() 50 private void InternData()
51 { 51 {
52 string temp = Encoding.UTF8.GetString(Data).Trim(); 52 string temp = Util.UTF8.GetString(Data).Trim();
53 string[] parts = temp.Split('\n'); 53 string[] parts = temp.Split('\n');
54 int.TryParse(parts[0].Substring(17, 1), out Version); 54 int.TryParse(parts[0].Substring(17, 1), out Version);
55 UUID.TryParse(parts[1].Substring(10, 36), out RegionID); 55 UUID.TryParse(parts[1].Substring(10, 36), out RegionID);
diff --git a/OpenSim/Framework/Capabilities/LLSD.cs b/OpenSim/Framework/Capabilities/LLSD.cs
index 84f43c1..eec9e61 100644
--- a/OpenSim/Framework/Capabilities/LLSD.cs
+++ b/OpenSim/Framework/Capabilities/LLSD.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Framework.Capabilities
112 112
113 writer.Close(); 113 writer.Close();
114 114
115 return Encoding.UTF8.GetBytes(sw.ToString()); 115 return Util.UTF8.GetBytes(sw.ToString());
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
@@ -329,7 +329,7 @@ namespace OpenSim.Framework.Capabilities
329 329
330 reader.Read(); 330 reader.Read();
331 FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces); 331 FromBase64Transform b64 = new FromBase64Transform(FromBase64TransformMode.IgnoreWhiteSpaces);
332 byte[] inp = Encoding.UTF8.GetBytes(reader.ReadString()); 332 byte[] inp = Util.UTF8.GetBytes(reader.ReadString());
333 ret = b64.TransformFinalBlock(inp, 0, inp.Length); 333 ret = b64.TransformFinalBlock(inp, 0, inp.Length);
334 break; 334 break;
335 } 335 }
diff --git a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs b/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs
index df48b35..7aaa994 100644
--- a/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs
+++ b/OpenSim/Framework/Capabilities/LLSDStreamHandler.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Framework.Capabilities
47 public override byte[] Handle(string path, Stream request, 47 public override byte[] Handle(string path, Stream request,
48 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 48 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
49 { 49 {
50 //Encoding encoding = Encoding.UTF8; 50 //Encoding encoding = Util.UTF8;
51 //StreamReader streamReader = new StreamReader(request, false); 51 //StreamReader streamReader = new StreamReader(request, false);
52 52
53 //string requestBody = streamReader.ReadToEnd(); 53 //string requestBody = streamReader.ReadToEnd();
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs
index 3419ce2..10be069 100644
--- a/OpenSim/Framework/Communications/Clients/RegionClient.cs
+++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs
@@ -106,7 +106,6 @@ namespace OpenSim.Framework.Communications.Clients
106 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send 106 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
107 os = AgentCreateRequest.GetRequestStream(); 107 os = AgentCreateRequest.GetRequestStream();
108 os.Write(buffer, 0, strBuffer.Length); //Send it 108 os.Write(buffer, 0, strBuffer.Length); //Send it
109 os.Close();
110 //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); 109 //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri);
111 } 110 }
112 //catch (WebException ex) 111 //catch (WebException ex)
@@ -116,6 +115,11 @@ namespace OpenSim.Framework.Communications.Clients
116 reason = "cannot contact remote region"; 115 reason = "cannot contact remote region";
117 return false; 116 return false;
118 } 117 }
118 finally
119 {
120 if (os != null)
121 os.Close();
122 }
119 123
120 // Let's wait for the response 124 // Let's wait for the response
121 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); 125 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@@ -224,7 +228,6 @@ namespace OpenSim.Framework.Communications.Clients
224 ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send 228 ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send
225 os = ChildUpdateRequest.GetRequestStream(); 229 os = ChildUpdateRequest.GetRequestStream();
226 os.Write(buffer, 0, strBuffer.Length); //Send it 230 os.Write(buffer, 0, strBuffer.Length); //Send it
227 os.Close();
228 //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); 231 //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
229 } 232 }
230 //catch (WebException ex) 233 //catch (WebException ex)
@@ -234,6 +237,11 @@ namespace OpenSim.Framework.Communications.Clients
234 237
235 return false; 238 return false;
236 } 239 }
240 finally
241 {
242 if (os != null)
243 os.Close();
244 }
237 245
238 // Let's wait for the response 246 // Let's wait for the response
239 //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); 247 //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate");
@@ -437,7 +445,6 @@ namespace OpenSim.Framework.Communications.Clients
437 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send 445 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
438 os = ObjectCreateRequest.GetRequestStream(); 446 os = ObjectCreateRequest.GetRequestStream();
439 os.Write(buffer, 0, strBuffer.Length); //Send it 447 os.Write(buffer, 0, strBuffer.Length); //Send it
440 os.Close();
441 m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); 448 m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
442 } 449 }
443 //catch (WebException ex) 450 //catch (WebException ex)
@@ -447,6 +454,11 @@ namespace OpenSim.Framework.Communications.Clients
447 454
448 return false; 455 return false;
449 } 456 }
457 finally
458 {
459 if (os != null)
460 os.Close();
461 }
450 462
451 // Let's wait for the response 463 // Let's wait for the response
452 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); 464 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@@ -512,7 +524,6 @@ namespace OpenSim.Framework.Communications.Clients
512 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send 524 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
513 os = ObjectCreateRequest.GetRequestStream(); 525 os = ObjectCreateRequest.GetRequestStream();
514 os.Write(buffer, 0, strBuffer.Length); //Send it 526 os.Write(buffer, 0, strBuffer.Length); //Send it
515 os.Close();
516 //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); 527 //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri);
517 } 528 }
518 //catch (WebException ex) 529 //catch (WebException ex)
@@ -522,6 +533,11 @@ namespace OpenSim.Framework.Communications.Clients
522 533
523 return false; 534 return false;
524 } 535 }
536 finally
537 {
538 if (os != null)
539 os.Close();
540 }
525 541
526 // Let's wait for the response 542 // Let's wait for the response
527 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); 543 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
@@ -597,7 +613,6 @@ namespace OpenSim.Framework.Communications.Clients
597 HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send 613 HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send
598 os = HelloNeighbourRequest.GetRequestStream(); 614 os = HelloNeighbourRequest.GetRequestStream();
599 os.Write(buffer, 0, strBuffer.Length); //Send it 615 os.Write(buffer, 0, strBuffer.Length); //Send it
600 os.Close();
601 //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); 616 //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri);
602 } 617 }
603 //catch (WebException ex) 618 //catch (WebException ex)
@@ -607,7 +622,11 @@ namespace OpenSim.Framework.Communications.Clients
607 622
608 return false; 623 return false;
609 } 624 }
610 625 finally
626 {
627 if (os != null)
628 os.Close();
629 }
611 // Let's wait for the response 630 // Let's wait for the response
612 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); 631 //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
613 632
diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs
index b52eda7..415d808 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs
+++ b/OpenSim/Framework/Communications/XMPP/XmppWriter.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Framework.Communications.XMPP
38 { 38 {
39 } 39 }
40 40
41 public XMPPWriter(IOStream stream) : this(stream, Encoding.UTF8) 41 public XMPPWriter(IOStream stream) : this(stream, Util.UTF8)
42 { 42 {
43 } 43 }
44 44
diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
index 318d2c3..3dce578 100644
--- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
+++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Framework.Configuration.HTTP
77 count = resStream.Read(buf, 0, buf.Length); 77 count = resStream.Read(buf, 0, buf.Length);
78 if (count != 0) 78 if (count != 0)
79 { 79 {
80 tempString = Encoding.UTF8.GetString(buf, 0, count); 80 tempString = Util.UTF8.GetString(buf, 0, count);
81 sb.Append(tempString); 81 sb.Append(tempString);
82 } 82 }
83 } while (count > 0); 83 } while (count > 0);
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
index 5afa110..03c12dd 100644
--- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
@@ -91,24 +91,35 @@ namespace OpenSim.Framework.Servers.HttpServer
91 Stream requestStream = request.EndGetRequestStream(res); 91 Stream requestStream = request.EndGetRequestStream(res);
92 92
93 requestStream.Write(buffer.ToArray(), 0, length); 93 requestStream.Write(buffer.ToArray(), 0, length);
94 requestStream.Close();
94 95
95 request.BeginGetResponse(delegate(IAsyncResult ar) 96 request.BeginGetResponse(delegate(IAsyncResult ar)
96 { 97 {
97 response = request.EndGetResponse(ar); 98 response = request.EndGetResponse(ar);
98 99 Stream respStream = null;
99 try 100 try
100 { 101 {
101 deserial = (TResponse) deserializer.Deserialize( 102 respStream = response.GetResponseStream();
102 response.GetResponseStream()); 103 deserial = (TResponse)deserializer.Deserialize(
104 respStream);
103 } 105 }
104 catch (System.InvalidOperationException) 106 catch (System.InvalidOperationException)
105 { 107 {
106 } 108 }
109 finally
110 {
111 // Let's not close this
112 //buffer.Close();
113 respStream.Close();
114 response.Close();
115 }
107 116
108 action(deserial); 117 action(deserial);
118
109 }, null); 119 }, null);
110 }, null); 120 }, null);
111 121
122
112 return; 123 return;
113 } 124 }
114 125
@@ -119,14 +130,21 @@ namespace OpenSim.Framework.Servers.HttpServer
119 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't 130 // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't
120 // documented in MSDN 131 // documented in MSDN
121 response = request.EndGetResponse(res2); 132 response = request.EndGetResponse(res2);
122 133
134 Stream respStream = null;
123 try 135 try
124 { 136 {
125 deserial = (TResponse)deserializer.Deserialize(response.GetResponseStream()); 137 respStream = response.GetResponseStream();
138 deserial = (TResponse)deserializer.Deserialize(respStream);
126 } 139 }
127 catch (System.InvalidOperationException) 140 catch (System.InvalidOperationException)
128 { 141 {
129 } 142 }
143 finally
144 {
145 respStream.Close();
146 response.Close();
147 }
130 } 148 }
131 catch (WebException e) 149 catch (WebException e)
132 { 150 {
@@ -148,7 +166,7 @@ namespace OpenSim.Framework.Servers.HttpServer
148 } 166 }
149 else 167 else
150 { 168 {
151 m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e); 169 m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message);
152 } 170 }
153 } 171 }
154 catch (Exception e) 172 catch (Exception e)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 6c63c6c..942fed9 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -979,7 +979,7 @@ namespace OpenSim.Framework.Servers.HttpServer
979 } 979 }
980 980
981 // response.ContentType = "application/llsd+json"; 981 // response.ContentType = "application/llsd+json";
982 // return Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse)); 982 // return Util.UTF8.GetBytes(OSDParser.SerializeJsonString(llsdResponse));
983 response.ContentType = "application/llsd+xml"; 983 response.ContentType = "application/llsd+xml";
984 return OSDParser.SerializeLLSDXmlBytes(llsdResponse); 984 return OSDParser.SerializeLLSDXmlBytes(llsdResponse);
985 } 985 }
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
index 3f72c31..7ebb462 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
@@ -94,13 +94,26 @@ namespace OpenSim.Framework.Servers.HttpServer
94 94
95 Stream requestStream = request.GetRequestStream(); 95 Stream requestStream = request.GetRequestStream();
96 requestStream.Write(buffer.ToArray(), 0, length); 96 requestStream.Write(buffer.ToArray(), 0, length);
97 buffer.Close();
97 requestStream.Close(); 98 requestStream.Close();
99
98 TResponse deserial = default(TResponse); 100 TResponse deserial = default(TResponse);
99 using (WebResponse resp = request.GetResponse()) 101 using (WebResponse resp = request.GetResponse())
100 { 102 {
101 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 103 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
102 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); 104 Stream respStream = null;
103 resp.Close(); 105 try
106 {
107 respStream = resp.GetResponseStream();
108 deserial = (TResponse)deserializer.Deserialize(respStream);
109 }
110 catch { }
111 finally
112 {
113 if (respStream != null)
114 respStream.Close();
115 resp.Close();
116 }
104 } 117 }
105 return deserial; 118 return deserial;
106 } 119 }
@@ -140,6 +153,7 @@ namespace OpenSim.Framework.Servers.HttpServer
140 serializer.Serialize(writer, sobj); 153 serializer.Serialize(writer, sobj);
141 writer.Flush(); 154 writer.Flush();
142 } 155 }
156 buffer.Close();
143 157
144 int length = (int)buffer.Length; 158 int length = (int)buffer.Length;
145 request.ContentLength = length; 159 request.ContentLength = length;
@@ -165,6 +179,8 @@ namespace OpenSim.Framework.Servers.HttpServer
165 // m_log.DebugFormat("[REST OBJECT POSTER RESPONSE]: Received {0}", reader.ReadToEnd()); 179 // m_log.DebugFormat("[REST OBJECT POSTER RESPONSE]: Received {0}", reader.ReadToEnd());
166 180
167 deserial = (TResponse)deserializer.Deserialize(stream); 181 deserial = (TResponse)deserializer.Deserialize(stream);
182 if (stream != null)
183 stream.Close();
168 184
169 if (deserial != null && ResponseCallback != null) 185 if (deserial != null && ResponseCallback != null)
170 { 186 {
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
index a0d4008..8a490f7 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -66,8 +66,23 @@ namespace OpenSim.Framework.Servers.HttpServer
66 length = (int)obj.Length; 66 length = (int)obj.Length;
67 request.ContentLength = length; 67 request.ContentLength = length;
68 68
69 Stream requestStream = request.GetRequestStream(); 69 Stream requestStream = null;
70 requestStream.Write(buffer.ToArray(), 0, length); 70 try
71 {
72 requestStream = request.GetRequestStream();
73 requestStream.Write(buffer.ToArray(), 0, length);
74 }
75 catch
76 {
77 }
78 finally
79 {
80 if (requestStream != null)
81 requestStream.Close();
82 // Let's not close this
83 //buffer.Close();
84
85 }
71 } 86 }
72 87
73 string respstring = String.Empty; 88 string respstring = String.Empty;
@@ -78,9 +93,20 @@ namespace OpenSim.Framework.Servers.HttpServer
78 { 93 {
79 if (resp.ContentLength > 0) 94 if (resp.ContentLength > 0)
80 { 95 {
81 using (StreamReader reader = new StreamReader(resp.GetResponseStream())) 96 Stream respStream = null;
97 try
98 {
99 respStream = resp.GetResponseStream();
100 using (StreamReader reader = new StreamReader(respStream))
101 {
102 respstring = reader.ReadToEnd();
103 }
104 }
105 catch { }
106 finally
82 { 107 {
83 respstring = reader.ReadToEnd(); 108 if (respStream != null)
109 respStream.Close();
84 } 110 }
85 } 111 }
86 } 112 }
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
index ec9bd4f..eab463c 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Framework.Servers.HttpServer
58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) 58 public static TResponse MakeRequest<TRequest, TResponse>(string verb, string requestUrl, TRequest obj)
59 { 59 {
60 Type type = typeof (TRequest); 60 Type type = typeof (TRequest);
61 TResponse deserial = default(TResponse);
61 62
62 WebRequest request = WebRequest.Create(requestUrl); 63 WebRequest request = WebRequest.Create(requestUrl);
63 request.Method = verb; 64 request.Method = verb;
@@ -81,19 +82,33 @@ namespace OpenSim.Framework.Servers.HttpServer
81 int length = (int) buffer.Length; 82 int length = (int) buffer.Length;
82 request.ContentLength = length; 83 request.ContentLength = length;
83 84
84 Stream requestStream = request.GetRequestStream(); 85 Stream requestStream = null;
85 requestStream.Write(buffer.ToArray(), 0, length); 86 try
87 {
88 requestStream = request.GetRequestStream();
89 requestStream.Write(buffer.ToArray(), 0, length);
90 }
91 catch (Exception)
92 {
93 return deserial;
94 }
95 finally
96 {
97 if (requestStream != null)
98 requestStream.Close();
99 }
86 } 100 }
87 101
88 TResponse deserial = default(TResponse);
89 try 102 try
90 { 103 {
91 using (WebResponse resp = request.GetResponse()) 104 using (WebResponse resp = request.GetResponse())
92 { 105 {
93 if (resp.ContentLength > 0) 106 if (resp.ContentLength > 0)
94 { 107 {
108 Stream respStream = resp.GetResponseStream();
95 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); 109 XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
96 deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); 110 deserial = (TResponse)deserializer.Deserialize(respStream);
111 respStream.Close();
97 } 112 }
98 } 113 }
99 } 114 }
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 17fc58c..0851d26 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -103,6 +103,8 @@ namespace OpenSim.Framework
103 } 103 }
104 104
105 105
106 public static Encoding UTF8 = Encoding.UTF8;
107
106 /// <value> 108 /// <value>
107 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards) 109 /// Well known UUID for the blank texture used in the Linden SL viewer version 1.20 (and hopefully onwards)
108 /// </value> 110 /// </value>
@@ -465,7 +467,7 @@ namespace OpenSim.Framework
465 output.Append(": "); 467 output.Append(": ");
466 } 468 }
467 469
468 output.Append(CleanString(Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1))); 470 output.Append(CleanString(Util.UTF8.GetString(bytes, 0, bytes.Length - 1)));
469 } 471 }
470 else 472 else
471 { 473 {
@@ -826,7 +828,7 @@ namespace OpenSim.Framework
826 828
827 public static string Compress(string text) 829 public static string Compress(string text)
828 { 830 {
829 byte[] buffer = Encoding.UTF8.GetBytes(text); 831 byte[] buffer = Util.UTF8.GetBytes(text);
830 MemoryStream memory = new MemoryStream(); 832 MemoryStream memory = new MemoryStream();
831 using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true)) 833 using (GZipStream compressor = new GZipStream(memory, CompressionMode.Compress, true))
832 { 834 {
@@ -860,7 +862,7 @@ namespace OpenSim.Framework
860 decompressor.Read(buffer, 0, buffer.Length); 862 decompressor.Read(buffer, 0, buffer.Length);
861 } 863 }
862 864
863 return Encoding.UTF8.GetString(buffer); 865 return Util.UTF8.GetString(buffer);
864 } 866 }
865 } 867 }
866 868
@@ -1132,7 +1134,7 @@ namespace OpenSim.Framework
1132 { 1134 {
1133 byte[] data = new byte[length]; 1135 byte[] data = new byte[length];
1134 stream.Read(data, 0, length); 1136 stream.Read(data, 0, length);
1135 string strdata = Encoding.UTF8.GetString(data); 1137 string strdata = Util.UTF8.GetString(data);
1136 OSDMap args = null; 1138 OSDMap args = null;
1137 OSD buffer; 1139 OSD buffer;
1138 buffer = OSDParser.DeserializeJson(strdata); 1140 buffer = OSDParser.DeserializeJson(strdata);