Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already.
parent
c80009e86c
commit
ce2bf496a4
|
@ -44,7 +44,6 @@ namespace OpenSim.ConsoleClient
|
||||||
ReplyDelegate action)
|
ReplyDelegate action)
|
||||||
{
|
{
|
||||||
WebRequest request = WebRequest.Create(requestUrl);
|
WebRequest request = WebRequest.Create(requestUrl);
|
||||||
WebResponse response = null;
|
|
||||||
|
|
||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
|
|
||||||
|
@ -64,16 +63,18 @@ namespace OpenSim.ConsoleClient
|
||||||
{
|
{
|
||||||
string reply = String.Empty;
|
string reply = String.Empty;
|
||||||
|
|
||||||
response = request.EndGetResponse(ar);
|
using (WebResponse response = request.EndGetResponse(ar))
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
StreamReader r = new StreamReader(response.GetResponseStream());
|
try
|
||||||
reply = r.ReadToEnd();
|
{
|
||||||
|
using (Stream s = response.GetResponseStream())
|
||||||
|
using (StreamReader r = new StreamReader(s))
|
||||||
|
reply = r.ReadToEnd();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (System.InvalidOperationException)
|
catch (System.InvalidOperationException)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action(requestUrl, data, reply);
|
action(requestUrl, data, reply);
|
||||||
|
|
|
@ -65,23 +65,27 @@ namespace OpenSim.Framework.Configuration.HTTP
|
||||||
byte[] buf = new byte[8192];
|
byte[] buf = new byte[8192];
|
||||||
HttpWebRequest request =
|
HttpWebRequest request =
|
||||||
(HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
|
(HttpWebRequest) WebRequest.Create(remoteConfigSettings.baseConfigURL + configFileName);
|
||||||
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
|
||||||
Stream resStream = response.GetResponseStream();
|
|
||||||
|
|
||||||
string tempString = null;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
count = resStream.Read(buf, 0, buf.Length);
|
using (Stream resStream = response.GetResponseStream())
|
||||||
if (count != 0)
|
|
||||||
{
|
{
|
||||||
tempString = Util.UTF8.GetString(buf, 0, count);
|
string tempString = null;
|
||||||
sb.Append(tempString);
|
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)
|
catch (WebException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,16 +74,26 @@ namespace OpenSim.Framework.RegionLoader.Web
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
|
|
||||||
m_log.Debug("[WEBLOADER]: Downloading region information...");
|
|
||||||
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
|
|
||||||
string xmlSource = String.Empty;
|
string xmlSource = String.Empty;
|
||||||
string tempStr = reader.ReadLine();
|
|
||||||
while (tempStr != null)
|
using (HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse())
|
||||||
{
|
{
|
||||||
xmlSource = xmlSource + tempStr;
|
m_log.Debug("[WEBLOADER]: Downloading region information...");
|
||||||
tempStr = reader.ReadLine();
|
|
||||||
|
using (Stream s = webResponse.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(s))
|
||||||
|
{
|
||||||
|
string tempStr = reader.ReadLine();
|
||||||
|
while (tempStr != null)
|
||||||
|
{
|
||||||
|
xmlSource = xmlSource + tempStr;
|
||||||
|
tempStr = reader.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
|
m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
|
||||||
xmlSource.Length);
|
xmlSource.Length);
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
@ -107,17 +117,24 @@ namespace OpenSim.Framework.RegionLoader.Web
|
||||||
}
|
}
|
||||||
catch (WebException ex)
|
catch (WebException ex)
|
||||||
{
|
{
|
||||||
if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
|
using (HttpWebResponse response = (HttpWebResponse)ex.Response)
|
||||||
{
|
{
|
||||||
if (!allowRegionless)
|
if (response.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
{
|
||||||
|
if (!allowRegionless)
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
throw ex;
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regionCount > 0 | allowRegionless)
|
if (regionCount > 0 | allowRegionless)
|
||||||
|
{
|
||||||
return regionInfos;
|
return regionInfos;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.Error("[WEBLOADER]: No region configs were available.");
|
m_log.Error("[WEBLOADER]: No region configs were available.");
|
||||||
|
|
|
@ -101,20 +101,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
using (WebResponse resp = request.GetResponse())
|
using (WebResponse resp = request.GetResponse())
|
||||||
{
|
{
|
||||||
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
|
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
|
||||||
Stream respStream = null;
|
|
||||||
try
|
using (Stream respStream = resp.GetResponseStream())
|
||||||
{
|
|
||||||
respStream = resp.GetResponseStream();
|
|
||||||
deserial = (TResponse)deserializer.Deserialize(respStream);
|
deserial = (TResponse)deserializer.Deserialize(respStream);
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (respStream != null)
|
|
||||||
respStream.Close();
|
|
||||||
resp.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return deserial;
|
return deserial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,8 +228,8 @@ namespace OpenSim.Framework
|
||||||
errorMessage = we.Message;
|
errorMessage = we.Message;
|
||||||
if (we.Status == WebExceptionStatus.ProtocolError)
|
if (we.Status == WebExceptionStatus.ProtocolError)
|
||||||
{
|
{
|
||||||
HttpWebResponse webResponse = (HttpWebResponse)we.Response;
|
using (HttpWebResponse webResponse = (HttpWebResponse)we.Response)
|
||||||
errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription);
|
errorMessage = String.Format("[{0}] {1}", webResponse.StatusCode, webResponse.StatusDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -387,8 +387,8 @@ namespace OpenSim.Framework
|
||||||
errorMessage = we.Message;
|
errorMessage = we.Message;
|
||||||
if (we.Status == WebExceptionStatus.ProtocolError)
|
if (we.Status == WebExceptionStatus.ProtocolError)
|
||||||
{
|
{
|
||||||
HttpWebResponse webResponse = (HttpWebResponse)we.Response;
|
using (HttpWebResponse webResponse = (HttpWebResponse)we.Response)
|
||||||
errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription);
|
errorMessage = String.Format("[{0}] {1}",webResponse.StatusCode,webResponse.StatusDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -823,15 +823,16 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
if (e.Response is HttpWebResponse)
|
if (e.Response is HttpWebResponse)
|
||||||
{
|
{
|
||||||
HttpWebResponse httpResponse = (HttpWebResponse)e.Response;
|
using (HttpWebResponse httpResponse = (HttpWebResponse)e.Response)
|
||||||
|
|
||||||
if (httpResponse.StatusCode != HttpStatusCode.NotFound)
|
|
||||||
{
|
{
|
||||||
// We don't appear to be handling any other status codes, so log these feailures to that
|
if (httpResponse.StatusCode != HttpStatusCode.NotFound)
|
||||||
// people don't spend unnecessary hours hunting phantom bugs.
|
{
|
||||||
m_log.DebugFormat(
|
// We don't appear to be handling any other status codes, so log these feailures to that
|
||||||
"[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}",
|
// people don't spend unnecessary hours hunting phantom bugs.
|
||||||
verb, requestUrl, httpResponse.StatusCode);
|
m_log.DebugFormat(
|
||||||
|
"[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}",
|
||||||
|
verb, requestUrl, httpResponse.StatusCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -972,11 +973,9 @@ namespace OpenSim.Framework
|
||||||
Stream respStream = null;
|
Stream respStream = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
respStream = resp.GetResponseStream();
|
using (respStream = resp.GetResponseStream())
|
||||||
using (StreamReader reader = new StreamReader(respStream))
|
using (StreamReader reader = new StreamReader(respStream))
|
||||||
{
|
respstring = reader.ReadToEnd();
|
||||||
respstring = reader.ReadToEnd();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1102,10 +1101,11 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
if (resp.ContentLength != 0)
|
if (resp.ContentLength != 0)
|
||||||
{
|
{
|
||||||
Stream respStream = resp.GetResponseStream();
|
using (Stream respStream = resp.GetResponseStream())
|
||||||
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
|
{
|
||||||
deserial = (TResponse)deserializer.Deserialize(respStream);
|
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
|
||||||
respStream.Close();
|
deserial = (TResponse)deserializer.Deserialize(respStream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1117,14 +1117,15 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
catch (WebException e)
|
catch (WebException e)
|
||||||
{
|
{
|
||||||
HttpWebResponse hwr = (HttpWebResponse)e.Response;
|
using (HttpWebResponse hwr = (HttpWebResponse)e.Response)
|
||||||
|
{
|
||||||
if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound)
|
if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound)
|
||||||
return deserial;
|
return deserial;
|
||||||
else
|
else
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}",
|
"[SynchronousRestObjectRequester]: WebException for {0} {1} {2}: {3} {4}",
|
||||||
verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace);
|
verb, requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (System.InvalidOperationException)
|
catch (System.InvalidOperationException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -826,13 +826,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WebRequest request = HttpWebRequest.Create(url);
|
WebRequest request = HttpWebRequest.Create(url);
|
||||||
//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
|
|
||||||
//Ckrinke Stream str = null;
|
using (HttpWebResponse response = (HttpWebResponse)(request).GetResponse())
|
||||||
HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
|
|
||||||
if (response.StatusCode == HttpStatusCode.OK)
|
|
||||||
{
|
{
|
||||||
Bitmap image = new Bitmap(response.GetResponseStream());
|
if (response.StatusCode == HttpStatusCode.OK)
|
||||||
return image;
|
{
|
||||||
|
using (Stream s = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
Bitmap image = new Bitmap(s);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
|
@ -863,20 +863,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
}
|
}
|
||||||
|
|
||||||
string response_mapItems_reply = null;
|
string response_mapItems_reply = null;
|
||||||
{ // get the response
|
{
|
||||||
StreamReader sr = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WebResponse webResponse = mapitemsrequest.GetResponse();
|
using (WebResponse webResponse = mapitemsrequest.GetResponse())
|
||||||
if (webResponse != null)
|
|
||||||
{
|
{
|
||||||
sr = new StreamReader(webResponse.GetResponseStream());
|
if (webResponse != null)
|
||||||
response_mapItems_reply = sr.ReadToEnd().Trim();
|
{
|
||||||
}
|
using (Stream s = webResponse.GetResponseStream())
|
||||||
else
|
using (StreamReader sr = new StreamReader(s))
|
||||||
{
|
response_mapItems_reply = sr.ReadToEnd().Trim();
|
||||||
return new OSDMap();
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
return new OSDMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (WebException)
|
catch (WebException)
|
||||||
{
|
{
|
||||||
|
@ -903,11 +905,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
|
|
||||||
return responseMap;
|
return responseMap;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (sr != null)
|
|
||||||
sr.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
OSD rezResponse = null;
|
OSD rezResponse = null;
|
||||||
try
|
try
|
||||||
|
@ -921,6 +918,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
|
m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
|
||||||
responseMap["connect"] = OSD.FromBoolean(false);
|
responseMap["connect"] = OSD.FromBoolean(false);
|
||||||
|
|
||||||
lock (m_blacklistedregions)
|
lock (m_blacklistedregions)
|
||||||
{
|
{
|
||||||
if (!m_blacklistedregions.ContainsKey(regionhandle))
|
if (!m_blacklistedregions.ContainsKey(regionhandle))
|
||||||
|
|
|
@ -551,13 +551,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
|
||||||
reqStream.Close();
|
reqStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse();
|
using (HttpWebResponse fwdrsp = (HttpWebResponse)forwardreq.GetResponse())
|
||||||
Encoding encoding = Util.UTF8;
|
{
|
||||||
StreamReader fwdresponsestream = new StreamReader(fwdrsp.GetResponseStream(), encoding);
|
Encoding encoding = Util.UTF8;
|
||||||
fwdresponsestr = fwdresponsestream.ReadToEnd();
|
|
||||||
fwdresponsecontenttype = fwdrsp.ContentType;
|
using (Stream s = fwdrsp.GetResponseStream())
|
||||||
fwdresponsecode = (int)fwdrsp.StatusCode;
|
{
|
||||||
fwdresponsestream.Close();
|
using (StreamReader fwdresponsestream = new StreamReader(s))
|
||||||
|
{
|
||||||
|
fwdresponsestr = fwdresponsestream.ReadToEnd();
|
||||||
|
fwdresponsecontenttype = fwdrsp.ContentType;
|
||||||
|
fwdresponsecode = (int)fwdrsp.StatusCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
response["content_type"] = fwdresponsecontenttype;
|
response["content_type"] = fwdresponsecontenttype;
|
||||||
response["str_response_string"] = fwdresponsestr;
|
response["str_response_string"] = fwdresponsestr;
|
||||||
|
|
|
@ -1114,18 +1114,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
|
||||||
// Otherwise prepare the request
|
// Otherwise prepare the request
|
||||||
m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
|
m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
|
||||||
|
|
||||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
|
||||||
HttpWebResponse rsp = null;
|
|
||||||
|
|
||||||
// We are sending just parameters, no content
|
// We are sending just parameters, no content
|
||||||
req.ContentLength = 0;
|
req.ContentLength = 0;
|
||||||
|
|
||||||
// Send request and retrieve the response
|
// Send request and retrieve the response
|
||||||
rsp = (HttpWebResponse)req.GetResponse();
|
using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
|
||||||
|
using (Stream s = rsp.GetResponseStream())
|
||||||
XmlTextReader rdr = new XmlTextReader(rsp.GetResponseStream());
|
using (XmlTextReader rdr = new XmlTextReader(s))
|
||||||
doc.Load(rdr);
|
doc.Load(rdr);
|
||||||
rdr.Close();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1151,28 +1151,38 @@ namespace Nwc.XmlRpc
|
||||||
request.AllowWriteStreamBuffering = true;
|
request.AllowWriteStreamBuffering = true;
|
||||||
request.KeepAlive = !_disableKeepAlive;
|
request.KeepAlive = !_disableKeepAlive;
|
||||||
|
|
||||||
Stream stream = request.GetRequestStream();
|
using (Stream stream = request.GetRequestStream())
|
||||||
XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII);
|
{
|
||||||
_serializer.Serialize(xml, this);
|
using (XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII))
|
||||||
xml.Flush();
|
{
|
||||||
xml.Close();
|
_serializer.Serialize(xml, this);
|
||||||
|
xml.Flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
StreamReader input = new StreamReader(response.GetResponseStream());
|
|
||||||
|
|
||||||
string inputXml = input.ReadToEnd();
|
|
||||||
XmlRpcResponse resp;
|
XmlRpcResponse resp;
|
||||||
try
|
|
||||||
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
{
|
{
|
||||||
resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
|
using (Stream s = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader input = new StreamReader(s))
|
||||||
|
{
|
||||||
|
string inputXml = input.ReadToEnd();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
RequestResponse = inputXml;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
RequestResponse = inputXml;
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
input.Close();
|
|
||||||
response.Close();
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,6 @@ namespace OpenSim.Services.Connectors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual string Helo()
|
public virtual string Helo()
|
||||||
{
|
{
|
||||||
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
|
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI);
|
||||||
|
@ -82,10 +81,12 @@ namespace OpenSim.Services.Connectors
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WebResponse response = req.GetResponse();
|
using (WebResponse response = req.GetResponse())
|
||||||
if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
|
{
|
||||||
return string.Empty;
|
if (response.Headers.Get("X-Handlers-Provided") == null) // just in case this ever returns a null
|
||||||
return response.Headers.Get("X-Handlers-Provided");
|
return string.Empty;
|
||||||
|
return response.Headers.Get("X-Handlers-Provided");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +96,5 @@ namespace OpenSim.Services.Connectors
|
||||||
// fail
|
// fail
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -171,41 +171,45 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||||
// Let's wait for the response
|
// Let's wait for the response
|
||||||
//m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
|
//m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
|
||||||
|
|
||||||
WebResponse webResponse = null;
|
|
||||||
StreamReader sr = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
webResponse = AgentCreateRequest.GetResponse();
|
using (WebResponse webResponse = AgentCreateRequest.GetResponse())
|
||||||
if (webResponse == null)
|
|
||||||
{
|
{
|
||||||
m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
|
if (webResponse == null)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
sr = new StreamReader(webResponse.GetResponseStream());
|
|
||||||
string response = sr.ReadToEnd().Trim();
|
|
||||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
|
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(response))
|
|
||||||
{
|
{
|
||||||
try
|
m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Stream s = webResponse.GetResponseStream())
|
||||||
{
|
{
|
||||||
// we assume we got an OSDMap back
|
using (StreamReader sr = new StreamReader(s))
|
||||||
OSDMap r = Util.GetOSDMap(response);
|
{
|
||||||
bool success = r["success"].AsBoolean();
|
string response = sr.ReadToEnd().Trim();
|
||||||
reason = r["reason"].AsString();
|
m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
|
||||||
return success;
|
|
||||||
}
|
|
||||||
catch (NullReferenceException e)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
|
|
||||||
|
|
||||||
// check for old style response
|
if (!String.IsNullOrEmpty(response))
|
||||||
if (response.ToLower().StartsWith("true"))
|
{
|
||||||
return true;
|
try
|
||||||
|
{
|
||||||
|
// we assume we got an OSDMap back
|
||||||
|
OSDMap r = Util.GetOSDMap(response);
|
||||||
|
bool success = r["success"].AsBoolean();
|
||||||
|
reason = r["reason"].AsString();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
catch (NullReferenceException e)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
|
||||||
|
|
||||||
return false;
|
// check for old style response
|
||||||
|
if (response.ToLower().StartsWith("true"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,11 +220,6 @@ namespace OpenSim.Services.Connectors.Hypergrid
|
||||||
reason = "Destination did not reply";
|
reason = "Destination did not reply";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (sr != null)
|
|
||||||
sr.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -168,22 +168,27 @@ namespace OpenSim.Services.Connectors
|
||||||
// Let's wait for the response
|
// Let's wait for the response
|
||||||
//m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
|
//m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall");
|
||||||
|
|
||||||
StreamReader sr = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
WebResponse webResponse = helloNeighbourRequest.GetResponse();
|
using (WebResponse webResponse = helloNeighbourRequest.GetResponse())
|
||||||
if (webResponse == null)
|
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
if (webResponse == null)
|
||||||
"[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
|
{
|
||||||
thisRegion.RegionName, region.RegionName);
|
m_log.DebugFormat(
|
||||||
|
"[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}",
|
||||||
|
thisRegion.RegionName, region.RegionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Stream s = webResponse.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader sr = new StreamReader(s))
|
||||||
|
{
|
||||||
|
//reply = sr.ReadToEnd().Trim();
|
||||||
|
sr.ReadToEnd().Trim();
|
||||||
|
//m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sr = new StreamReader(webResponse.GetResponseStream());
|
|
||||||
//reply = sr.ReadToEnd().Trim();
|
|
||||||
sr.ReadToEnd().Trim();
|
|
||||||
//m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -193,11 +198,6 @@ namespace OpenSim.Services.Connectors
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (sr != null)
|
|
||||||
sr.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,35 +340,37 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
// By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
|
// By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs
|
||||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
|
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString());
|
||||||
|
|
||||||
HttpWebResponse response = MultipartForm.Post(request, postParameters);
|
using (HttpWebResponse response = MultipartForm.Post(request, postParameters))
|
||||||
using (Stream responseStream = response.GetResponseStream())
|
|
||||||
{
|
{
|
||||||
string responseStr = null;
|
using (Stream responseStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
string responseStr = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
|
||||||
responseStr = responseStream.GetStreamString();
|
|
||||||
OSD responseOSD = OSDParser.Deserialize(responseStr);
|
|
||||||
if (responseOSD.Type == OSDType.Map)
|
|
||||||
{
|
{
|
||||||
OSDMap responseMap = (OSDMap)responseOSD;
|
responseStr = responseStream.GetStreamString();
|
||||||
if (responseMap["Success"].AsBoolean())
|
OSD responseOSD = OSDParser.Deserialize(responseStr);
|
||||||
return asset.ID;
|
if (responseOSD.Type == OSDType.Map)
|
||||||
|
{
|
||||||
|
OSDMap responseMap = (OSDMap)responseOSD;
|
||||||
|
if (responseMap["Success"].AsBoolean())
|
||||||
|
return asset.ID;
|
||||||
|
else
|
||||||
|
errorMessage = "Upload failed: " + responseMap["Message"].AsString();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
errorMessage = "Upload failed: " + responseMap["Message"].AsString();
|
{
|
||||||
|
errorMessage = "Response format was invalid:\n" + responseStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
errorMessage = "Response format was invalid:\n" + responseStr;
|
if (!String.IsNullOrEmpty(responseStr))
|
||||||
|
errorMessage = "Failed to parse the response:\n" + responseStr;
|
||||||
|
else
|
||||||
|
errorMessage = "Failed to retrieve the response: " + ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrEmpty(responseStr))
|
|
||||||
errorMessage = "Failed to parse the response:\n" + responseStr;
|
|
||||||
else
|
|
||||||
errorMessage = "Failed to retrieve the response: " + ex.Message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (WebException ex)
|
catch (WebException ex)
|
||||||
|
@ -378,6 +380,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
||||||
|
|
||||||
m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
|
m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}",
|
||||||
asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
|
asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue