aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs')
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs68
1 files changed, 48 insertions, 20 deletions
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
index de4898a..a2f5d9c 100644
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
@@ -57,6 +57,8 @@ namespace OpenSim.Framework.RegionLoader.Web
57 { 57 {
58 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; 58 IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
59 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim(); 59 string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
60 bool allowRegionless = startupConfig.GetBoolean("allow_regionless", false);
61
60 if (url == String.Empty) 62 if (url == String.Empty)
61 { 63 {
62 m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty."); 64 m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
@@ -64,37 +66,63 @@ namespace OpenSim.Framework.RegionLoader.Web
64 } 66 }
65 else 67 else
66 { 68 {
69 RegionInfo[] regionInfos = new RegionInfo[] {};
70 int regionCount = 0;
67 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url); 71 HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
68 webRequest.Timeout = 30000; //30 Second Timeout 72 webRequest.Timeout = 30000; //30 Second Timeout
69 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url); 73 m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);
70 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); 74
71 m_log.Debug("[WEBLOADER]: Downloading region information..."); 75 try
72 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
73 string xmlSource = String.Empty;
74 string tempStr = reader.ReadLine();
75 while (tempStr != null)
76 { 76 {
77 xmlSource = xmlSource + tempStr; 77 HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
78 tempStr = reader.ReadLine(); 78 m_log.Debug("[WEBLOADER]: Downloading region information...");
79 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
80 string xmlSource = String.Empty;
81 string tempStr = reader.ReadLine();
82 while (tempStr != null)
83 {
84 xmlSource = xmlSource + tempStr;
85 tempStr = reader.ReadLine();
86 }
87 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
88 xmlSource.Length);
89 XmlDocument xmlDoc = new XmlDocument();
90 xmlDoc.LoadXml(xmlSource);
91 if (xmlDoc.FirstChild.Name == "Regions")
92 {
93 regionCount = xmlDoc.FirstChild.ChildNodes.Count;
94
95 if (regionCount > 0)
96 {
97 regionInfos = new RegionInfo[regionCount];
98 int i;
99 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
100 {
101 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
102 regionInfos[i] =
103 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
104 }
105 }
106 }
79 } 107 }
80 m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " + 108 catch (WebException ex)
81 xmlSource.Length);
82 XmlDocument xmlDoc = new XmlDocument();
83 xmlDoc.LoadXml(xmlSource);
84 if (xmlDoc.FirstChild.Name == "Regions")
85 { 109 {
86 RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; 110 if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
87 int i;
88 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
89 { 111 {
90 m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); 112 if (!allowRegionless)
91 regionInfos[i] = 113 throw ex;
92 new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
93 } 114 }
115 else
116 throw ex;
117 }
94 118
119 if (regionCount > 0 | allowRegionless)
95 return regionInfos; 120 return regionInfos;
121 else
122 {
123 m_log.Error("[WEBLOADER]: No region configs were available.");
124 return null;
96 } 125 }
97 return null;
98 } 126 }
99 } 127 }
100 } 128 }