diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs (renamed from OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs) | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs index a2f5d9c..850f3e0 100644 --- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/RegionLoaderWebServer.cs | |||
@@ -32,8 +32,9 @@ using System.Reflection; | |||
32 | using System.Xml; | 32 | using System.Xml; |
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | ||
35 | 36 | ||
36 | namespace OpenSim.Framework.RegionLoader.Web | 37 | namespace OpenSim.ApplicationPlugins.LoadRegions |
37 | { | 38 | { |
38 | public class RegionLoaderWebServer : IRegionLoader | 39 | public class RegionLoaderWebServer : IRegionLoader |
39 | { | 40 | { |
@@ -74,21 +75,31 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
74 | 75 | ||
75 | try | 76 | try |
76 | { | 77 | { |
77 | HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); | ||
78 | m_log.Debug("[WEBLOADER]: Downloading region information..."); | ||
79 | StreamReader reader = new StreamReader(webResponse.GetResponseStream()); | ||
80 | string xmlSource = String.Empty; | 78 | string xmlSource = String.Empty; |
81 | string tempStr = reader.ReadLine(); | 79 | |
82 | while (tempStr != null) | 80 | using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse()) |
83 | { | 81 | { |
84 | xmlSource = xmlSource + tempStr; | 82 | m_log.Debug("[WEBLOADER]: Downloading region information..."); |
85 | tempStr = reader.ReadLine(); | 83 | |
84 | using (Stream s = webResponse.GetResponseStream()) | ||
85 | { | ||
86 | using (StreamReader reader = new StreamReader(s)) | ||
87 | { | ||
88 | string tempStr = reader.ReadLine(); | ||
89 | while (tempStr != null) | ||
90 | { | ||
91 | xmlSource = xmlSource + tempStr; | ||
92 | tempStr = reader.ReadLine(); | ||
93 | } | ||
94 | } | ||
95 | } | ||
86 | } | 96 | } |
97 | |||
87 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + | 98 | m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + |
88 | xmlSource.Length); | 99 | xmlSource.Length); |
89 | XmlDocument xmlDoc = new XmlDocument(); | 100 | XmlDocument xmlDoc = new XmlDocument(); |
90 | xmlDoc.LoadXml(xmlSource); | 101 | xmlDoc.LoadXml(xmlSource); |
91 | if (xmlDoc.FirstChild.Name == "Regions") | 102 | if (xmlDoc.FirstChild.Name == "Nini") |
92 | { | 103 | { |
93 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; | 104 | regionCount = xmlDoc.FirstChild.ChildNodes.Count; |
94 | 105 | ||
@@ -107,17 +118,24 @@ namespace OpenSim.Framework.RegionLoader.Web | |||
107 | } | 118 | } |
108 | catch (WebException ex) | 119 | catch (WebException ex) |
109 | { | 120 | { |
110 | if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound) | 121 | using (HttpWebResponse response = (HttpWebResponse)ex.Response) |
111 | { | 122 | { |
112 | if (!allowRegionless) | 123 | if (response.StatusCode == HttpStatusCode.NotFound) |
124 | { | ||
125 | if (!allowRegionless) | ||
126 | throw ex; | ||
127 | } | ||
128 | else | ||
129 | { | ||
113 | throw ex; | 130 | throw ex; |
131 | } | ||
114 | } | 132 | } |
115 | else | ||
116 | throw ex; | ||
117 | } | 133 | } |
118 | 134 | ||
119 | if (regionCount > 0 | allowRegionless) | 135 | if (regionCount > 0 | allowRegionless) |
136 | { | ||
120 | return regionInfos; | 137 | return regionInfos; |
138 | } | ||
121 | else | 139 | else |
122 | { | 140 | { |
123 | m_log.Error("[WEBLOADER]: No region configs were available."); | 141 | m_log.Error("[WEBLOADER]: No region configs were available."); |