From 80c19b7cac52a57fd04966169c657400aeee3de8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Feb 2013 00:21:02 +0000 Subject: Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already. --- .../Configuration/HTTP/HTTPConfiguration.cs | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'OpenSim/Framework/Configuration') diff --git a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs index 3dce578..6681c37 100644 --- a/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs +++ b/OpenSim/Framework/Configuration/HTTP/HTTPConfiguration.cs @@ -65,23 +65,27 @@ namespace OpenSim.Framework.Configuration.HTTP byte[] buf = new byte[8192]; HttpWebRequest request = (HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName); - HttpWebResponse response = (HttpWebResponse) request.GetResponse(); - - Stream resStream = response.GetResponseStream(); - - string tempString = null; - int count = 0; - - do + using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { - count = resStream.Read(buf, 0, buf.Length); - if (count != 0) + using (Stream resStream = response.GetResponseStream()) { - tempString = Util.UTF8.GetString(buf, 0, count); - sb.Append(tempString); + string tempString = null; + int count = 0; + + do + { + count = resStream.Read(buf, 0, buf.Length); + if (count != 0) + { + tempString = Util.UTF8.GetString(buf, 0, count); + sb.Append(tempString); + } + } + while (count > 0); + + LoadDataFromString(sb.ToString()); } - } while (count > 0); - LoadDataFromString(sb.ToString()); + } } catch (WebException) { -- cgit v1.1