From 7592a033df4f81ba985e1d6f57ad0ef488dc5745 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Tue, 12 Apr 2011 20:24:28 -0700
Subject: Moved 3 request handlers from OpenSim.Framework.Servers.HttpServer up
to OpenSim.Framework -- just pasted them in WebUtil. This is so that code
that uses the Service connectors don't need to include the HttpServer dll --
that was odd.
---
.../HttpServer/AsynchronousRestObjectRequester.cs | 192 ------------
.../HttpServer/SynchronousRestFormsRequester.cs | 131 --------
.../HttpServer/SynchronousRestObjectRequester.cs | 122 --------
OpenSim/Framework/WebUtil.cs | 335 +++++++++++++++++++++
.../CoreModules/Avatar/Friends/FriendsModule.cs | 2 +-
.../Avatar/InstantMessage/OfflineMessageModule.cs | 1 -
.../Asset/AssetServiceInConnectorModule.cs | 1 -
.../AuthenticationServiceInConnectorModule.cs | 1 -
.../Grid/GridInfoServiceInConnectorModule.cs | 1 -
.../Hypergrid/HypergridServiceInConnectorModule.cs | 1 -
.../Inventory/InventoryServiceInConnectorModule.cs | 3 +-
.../Land/LandServiceInConnectorModule.cs | 1 -
.../Login/LLLoginServiceInConnectorModule.cs | 1 -
.../Neighbour/NeighbourServiceInConnectorModule.cs | 1 -
.../SimulationServiceInConnectorModule.cs | 1 -
.../Connectors/Asset/AssetServiceConnector.cs | 1 -
.../AuthenticationServiceConnector.cs | 1 -
.../Authorization/AuthorizationServiceConnector.cs | 1 -
.../Connectors/Avatar/AvatarServiceConnector.cs | 1 -
.../Freeswitch/RemoteFreeswitchConnector.cs | 1 -
.../Connectors/Friends/FriendsServiceConnector.cs | 1 -
.../Connectors/Friends/FriendsSimConnector.cs | 2 +-
.../Connectors/Grid/GridServiceConnector.cs | 1 -
.../GridUser/GridUserServiceConnector.cs | 1 -
.../Connectors/Inventory/XInventoryConnector.cs | 1 -
.../Connectors/Land/LandServiceConnector.cs | 1 -
.../Neighbour/NeighbourServiceConnector.cs | 1 -
.../Presence/PresenceServiceConnector.cs | 1 -
.../UserAccounts/UserAccountServiceConnector.cs | 1 -
29 files changed, 338 insertions(+), 471 deletions(-)
delete mode 100644 OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
delete mode 100644 OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
delete mode 100644 OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
deleted file mode 100644
index 03c12dd..0000000
--- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using System.Text;
-using System.Xml;
-using System.Xml.Serialization;
-using log4net;
-
-namespace OpenSim.Framework.Servers.HttpServer
-{
- public class AsynchronousRestObjectRequester
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Perform an asynchronous REST request.
- ///
- /// GET or POST
- ///
- ///
- ///
- ///
- ///
- /// Thrown if we encounter a
- /// network issue while posting the request. You'll want to make
- /// sure you deal with this as they're not uncommon
- //
- public static void MakeRequest(string verb,
- string requestUrl, TRequest obj, Action action)
- {
-// m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl);
-
- Type type = typeof (TRequest);
-
- WebRequest request = WebRequest.Create(requestUrl);
- WebResponse response = null;
- TResponse deserial = default(TResponse);
- XmlSerializer deserializer = new XmlSerializer(typeof (TResponse));
-
- request.Method = verb;
-
- if (verb == "POST")
- {
- request.ContentType = "text/xml";
-
- MemoryStream buffer = new MemoryStream();
-
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Encoding = Encoding.UTF8;
-
- using (XmlWriter writer = XmlWriter.Create(buffer, settings))
- {
- XmlSerializer serializer = new XmlSerializer(type);
- serializer.Serialize(writer, obj);
- writer.Flush();
- }
-
- int length = (int) buffer.Length;
- request.ContentLength = length;
-
- request.BeginGetRequestStream(delegate(IAsyncResult res)
- {
- Stream requestStream = request.EndGetRequestStream(res);
-
- requestStream.Write(buffer.ToArray(), 0, length);
- requestStream.Close();
-
- request.BeginGetResponse(delegate(IAsyncResult ar)
- {
- response = request.EndGetResponse(ar);
- Stream respStream = null;
- try
- {
- respStream = response.GetResponseStream();
- deserial = (TResponse)deserializer.Deserialize(
- respStream);
- }
- catch (System.InvalidOperationException)
- {
- }
- finally
- {
- // Let's not close this
- //buffer.Close();
- respStream.Close();
- response.Close();
- }
-
- action(deserial);
-
- }, null);
- }, null);
-
-
- return;
- }
-
- request.BeginGetResponse(delegate(IAsyncResult res2)
- {
- try
- {
- // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't
- // documented in MSDN
- response = request.EndGetResponse(res2);
-
- Stream respStream = null;
- try
- {
- respStream = response.GetResponseStream();
- deserial = (TResponse)deserializer.Deserialize(respStream);
- }
- catch (System.InvalidOperationException)
- {
- }
- finally
- {
- respStream.Close();
- response.Close();
- }
- }
- catch (WebException e)
- {
- if (e.Status == WebExceptionStatus.ProtocolError)
- {
- if (e.Response is HttpWebResponse)
- {
- 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
- // people don't spend unnecessary hours hunting phantom bugs.
- m_log.DebugFormat(
- "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}",
- verb, requestUrl, httpResponse.StatusCode);
- }
- }
- }
- else
- {
- m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message);
- }
- }
- catch (Exception e)
- {
- m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e);
- }
-
- // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString());
-
- try
- {
- action(deserial);
- }
- catch (Exception e)
- {
- m_log.ErrorFormat(
- "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e);
- }
-
- }, null);
- }
- }
-}
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
deleted file mode 100644
index 41ece86..0000000
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.IO;
-using System.Net;
-using System.Reflection;
-using System.Text;
-using System.Xml;
-using System.Xml.Serialization;
-
-using log4net;
-
-namespace OpenSim.Framework.Servers.HttpServer
-{
- public class SynchronousRestFormsRequester
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(
- MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Perform a synchronous REST request.
- ///
- ///
- ///
- ///
- ///
- ///
- /// Thrown if we encounter a network issue while posting
- /// the request. You'll want to make sure you deal with this as they're not uncommon
- public static string MakeRequest(string verb, string requestUrl, string obj)
- {
- WebRequest request = WebRequest.Create(requestUrl);
- request.Method = verb;
- string respstring = String.Empty;
-
- using (MemoryStream buffer = new MemoryStream())
- {
- if ((verb == "POST") || (verb == "PUT"))
- {
- request.ContentType = "text/www-form-urlencoded";
-
- int length = 0;
- using (StreamWriter writer = new StreamWriter(buffer))
- {
- writer.Write(obj);
- writer.Flush();
- }
-
- length = (int)obj.Length;
- request.ContentLength = length;
-
- Stream requestStream = null;
- try
- {
- requestStream = request.GetRequestStream();
- requestStream.Write(buffer.ToArray(), 0, length);
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[FORMS]: exception occured on sending request to {0}: " + e.ToString(), requestUrl);
- }
- finally
- {
- if (requestStream != null)
- requestStream.Close();
- }
- }
-
- try
- {
- using (WebResponse resp = request.GetResponse())
- {
- if (resp.ContentLength != 0)
- {
- Stream respStream = null;
- try
- {
- respStream = resp.GetResponseStream();
- using (StreamReader reader = new StreamReader(respStream))
- {
- respstring = reader.ReadToEnd();
- }
- }
- catch (Exception e)
- {
- m_log.DebugFormat("[FORMS]: exception occured on receiving reply " + e.ToString());
- }
- finally
- {
- if (respStream != null)
- respStream.Close();
- }
- }
- }
- }
- catch (System.InvalidOperationException)
- {
- // This is what happens when there is invalid XML
- m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request");
- }
- }
- return respstring;
- }
- }
-}
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
deleted file mode 100644
index eab463c..0000000
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestObjectRequester.cs
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Xml;
-using System.Xml.Serialization;
-
-namespace OpenSim.Framework.Servers.HttpServer
-{
- public class SynchronousRestObjectPoster
- {
- [Obsolete]
- public static TResponse BeginPostObject(string verb, string requestUrl, TRequest obj)
- {
- return SynchronousRestObjectRequester.MakeRequest(verb, requestUrl, obj);
- }
- }
-
- public class SynchronousRestObjectRequester
- {
- ///
- /// Perform a synchronous REST request.
- ///
- ///
- ///
- ///
- ///
- ///
- /// Thrown if we encounter a network issue while posting
- /// the request. You'll want to make sure you deal with this as they're not uncommon
- public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj)
- {
- Type type = typeof (TRequest);
- TResponse deserial = default(TResponse);
-
- WebRequest request = WebRequest.Create(requestUrl);
- request.Method = verb;
-
- if ((verb == "POST") || (verb == "PUT"))
- {
- request.ContentType = "text/xml";
-
- MemoryStream buffer = new MemoryStream();
-
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Encoding = Encoding.UTF8;
-
- using (XmlWriter writer = XmlWriter.Create(buffer, settings))
- {
- XmlSerializer serializer = new XmlSerializer(type);
- serializer.Serialize(writer, obj);
- writer.Flush();
- }
-
- int length = (int) buffer.Length;
- request.ContentLength = length;
-
- Stream requestStream = null;
- try
- {
- requestStream = request.GetRequestStream();
- requestStream.Write(buffer.ToArray(), 0, length);
- }
- catch (Exception)
- {
- return deserial;
- }
- finally
- {
- if (requestStream != null)
- requestStream.Close();
- }
- }
-
- try
- {
- using (WebResponse resp = request.GetResponse())
- {
- if (resp.ContentLength > 0)
- {
- Stream respStream = resp.GetResponseStream();
- XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
- deserial = (TResponse)deserializer.Deserialize(respStream);
- respStream.Close();
- }
- }
- }
- catch (System.InvalidOperationException)
- {
- // This is what happens when there is invalid XML
- }
- return deserial;
- }
- }
-}
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
index 1feeeb3..64cd014 100644
--- a/OpenSim/Framework/WebUtil.cs
+++ b/OpenSim/Framework/WebUtil.cs
@@ -36,6 +36,9 @@ using System.Net.Security;
using System.Reflection;
using System.Text;
using System.Web;
+using System.Xml;
+using System.Xml.Serialization;
+
using log4net;
using OpenSim.Framework.Servers.HttpServer;
using OpenMetaverse.StructuredData;
@@ -625,4 +628,336 @@ namespace OpenSim.Framework
}
+
+ public static class AsynchronousRestObjectRequester
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Perform an asynchronous REST request.
+ ///
+ /// GET or POST
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Thrown if we encounter a
+ /// network issue while posting the request. You'll want to make
+ /// sure you deal with this as they're not uncommon
+ //
+ public static void MakeRequest(string verb,
+ string requestUrl, TRequest obj, Action action)
+ {
+ // m_log.DebugFormat("[ASYNC REQUEST]: Starting {0} {1}", verb, requestUrl);
+
+ Type type = typeof(TRequest);
+
+ WebRequest request = WebRequest.Create(requestUrl);
+ WebResponse response = null;
+ TResponse deserial = default(TResponse);
+ XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
+
+ request.Method = verb;
+
+ if (verb == "POST")
+ {
+ request.ContentType = "text/xml";
+
+ MemoryStream buffer = new MemoryStream();
+
+ XmlWriterSettings settings = new XmlWriterSettings();
+ settings.Encoding = Encoding.UTF8;
+
+ using (XmlWriter writer = XmlWriter.Create(buffer, settings))
+ {
+ XmlSerializer serializer = new XmlSerializer(type);
+ serializer.Serialize(writer, obj);
+ writer.Flush();
+ }
+
+ int length = (int)buffer.Length;
+ request.ContentLength = length;
+
+ request.BeginGetRequestStream(delegate(IAsyncResult res)
+ {
+ Stream requestStream = request.EndGetRequestStream(res);
+
+ requestStream.Write(buffer.ToArray(), 0, length);
+ requestStream.Close();
+
+ request.BeginGetResponse(delegate(IAsyncResult ar)
+ {
+ response = request.EndGetResponse(ar);
+ Stream respStream = null;
+ try
+ {
+ respStream = response.GetResponseStream();
+ deserial = (TResponse)deserializer.Deserialize(
+ respStream);
+ }
+ catch (System.InvalidOperationException)
+ {
+ }
+ finally
+ {
+ // Let's not close this
+ //buffer.Close();
+ respStream.Close();
+ response.Close();
+ }
+
+ action(deserial);
+
+ }, null);
+ }, null);
+
+
+ return;
+ }
+
+ request.BeginGetResponse(delegate(IAsyncResult res2)
+ {
+ try
+ {
+ // If the server returns a 404, this appears to trigger a System.Net.WebException even though that isn't
+ // documented in MSDN
+ response = request.EndGetResponse(res2);
+
+ Stream respStream = null;
+ try
+ {
+ respStream = response.GetResponseStream();
+ deserial = (TResponse)deserializer.Deserialize(respStream);
+ }
+ catch (System.InvalidOperationException)
+ {
+ }
+ finally
+ {
+ respStream.Close();
+ response.Close();
+ }
+ }
+ catch (WebException e)
+ {
+ if (e.Status == WebExceptionStatus.ProtocolError)
+ {
+ if (e.Response is HttpWebResponse)
+ {
+ 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
+ // people don't spend unnecessary hours hunting phantom bugs.
+ m_log.DebugFormat(
+ "[ASYNC REQUEST]: Request {0} {1} failed with unexpected status code {2}",
+ verb, requestUrl, httpResponse.StatusCode);
+ }
+ }
+ }
+ else
+ {
+ m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with status {2} and message {3}", verb, requestUrl, e.Status, e.Message);
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[ASYNC REQUEST]: Request {0} {1} failed with exception {2}", verb, requestUrl, e);
+ }
+
+ // m_log.DebugFormat("[ASYNC REQUEST]: Received {0}", deserial.ToString());
+
+ try
+ {
+ action(deserial);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat(
+ "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e);
+ }
+
+ }, null);
+ }
+ }
+
+ public static class SynchronousRestFormsRequester
+ {
+ private static readonly ILog m_log =
+ LogManager.GetLogger(
+ MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Perform a synchronous REST request.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Thrown if we encounter a network issue while posting
+ /// the request. You'll want to make sure you deal with this as they're not uncommon
+ public static string MakeRequest(string verb, string requestUrl, string obj)
+ {
+ WebRequest request = WebRequest.Create(requestUrl);
+ request.Method = verb;
+ string respstring = String.Empty;
+
+ using (MemoryStream buffer = new MemoryStream())
+ {
+ if ((verb == "POST") || (verb == "PUT"))
+ {
+ request.ContentType = "text/www-form-urlencoded";
+
+ int length = 0;
+ using (StreamWriter writer = new StreamWriter(buffer))
+ {
+ writer.Write(obj);
+ writer.Flush();
+ }
+
+ length = (int)obj.Length;
+ request.ContentLength = length;
+
+ Stream requestStream = null;
+ try
+ {
+ requestStream = request.GetRequestStream();
+ requestStream.Write(buffer.ToArray(), 0, length);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[FORMS]: exception occured on sending request to {0}: " + e.ToString(), requestUrl);
+ }
+ finally
+ {
+ if (requestStream != null)
+ requestStream.Close();
+ }
+ }
+
+ try
+ {
+ using (WebResponse resp = request.GetResponse())
+ {
+ if (resp.ContentLength != 0)
+ {
+ Stream respStream = null;
+ try
+ {
+ respStream = resp.GetResponseStream();
+ using (StreamReader reader = new StreamReader(respStream))
+ {
+ respstring = reader.ReadToEnd();
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[FORMS]: exception occured on receiving reply " + e.ToString());
+ }
+ finally
+ {
+ if (respStream != null)
+ respStream.Close();
+ }
+ }
+ }
+ }
+ catch (System.InvalidOperationException)
+ {
+ // This is what happens when there is invalid XML
+ m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request");
+ }
+ }
+ return respstring;
+ }
+ }
+
+ public class SynchronousRestObjectPoster
+ {
+ [Obsolete]
+ public static TResponse BeginPostObject(string verb, string requestUrl, TRequest obj)
+ {
+ return SynchronousRestObjectRequester.MakeRequest(verb, requestUrl, obj);
+ }
+ }
+
+ public class SynchronousRestObjectRequester
+ {
+ ///
+ /// Perform a synchronous REST request.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// Thrown if we encounter a network issue while posting
+ /// the request. You'll want to make sure you deal with this as they're not uncommon
+ public static TResponse MakeRequest(string verb, string requestUrl, TRequest obj)
+ {
+ Type type = typeof(TRequest);
+ TResponse deserial = default(TResponse);
+
+ WebRequest request = WebRequest.Create(requestUrl);
+ request.Method = verb;
+
+ if ((verb == "POST") || (verb == "PUT"))
+ {
+ request.ContentType = "text/xml";
+
+ MemoryStream buffer = new MemoryStream();
+
+ XmlWriterSettings settings = new XmlWriterSettings();
+ settings.Encoding = Encoding.UTF8;
+
+ using (XmlWriter writer = XmlWriter.Create(buffer, settings))
+ {
+ XmlSerializer serializer = new XmlSerializer(type);
+ serializer.Serialize(writer, obj);
+ writer.Flush();
+ }
+
+ int length = (int)buffer.Length;
+ request.ContentLength = length;
+
+ Stream requestStream = null;
+ try
+ {
+ requestStream = request.GetRequestStream();
+ requestStream.Write(buffer.ToArray(), 0, length);
+ }
+ catch (Exception)
+ {
+ return deserial;
+ }
+ finally
+ {
+ if (requestStream != null)
+ requestStream.Close();
+ }
+ }
+
+ try
+ {
+ using (WebResponse resp = request.GetResponse())
+ {
+ if (resp.ContentLength > 0)
+ {
+ Stream respStream = resp.GetResponseStream();
+ XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
+ deserial = (TResponse)deserializer.Deserialize(respStream);
+ respStream.Close();
+ }
+ }
+ }
+ catch (System.InvalidOperationException)
+ {
+ // This is what happens when there is invalid XML
+ }
+ return deserial;
+ }
+ }
}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 4d74b2a..5baf078 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -34,13 +34,13 @@ using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Friends;
using OpenSim.Server.Base;
-using OpenSim.Framework.Servers.HttpServer;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index fdfcd10..919ea33 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -33,7 +33,6 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
index e25700d..422f394 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
index 02acddc..2b5beba 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
index 6d975af..f29c074 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
index 2f96bcb..d2343c9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
index 209cf0d..53a8ace 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs
@@ -31,9 +31,8 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
-using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes;
using OpenSim.Server.Base;
using OpenSim.Server.Handlers.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
index fcc69e9..fc64203 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
index 2a9366c..f759470 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
index 35518d5..5c32632 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
index 5ee1c97..86b4926 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
using log4net;
using Nini.Config;
using OpenSim.Framework;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Server.Base;
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
index 65b3537..f1da4fa 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
@@ -34,7 +34,6 @@ using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
index 6f77a2d..c04e7a4 100644
--- a/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authentication/AuthenticationServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
index 4eb4bd2..35b7109 100644
--- a/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Authorization/AuthorizationServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
index 1cd6bf8..1a93ae7 100644
--- a/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Avatar/AvatarServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using IAvatarService = OpenSim.Services.Interfaces.IAvatarService;
diff --git a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
index c9bba0b..d688299 100644
--- a/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
+++ b/OpenSim/Services/Connectors/Freeswitch/RemoteFreeswitchConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
index 36b5083..861c475 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenSim.Server.Base;
diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
index 0a7b277..4ffa68c 100644
--- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
+++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs
@@ -32,7 +32,7 @@ using System.Reflection;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
-using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Framework;
using OpenMetaverse;
using log4net;
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 5092d74..e57f28b 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
index b3ea865..738cc06 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
index b3bfcc2..cd9f2bf 100644
--- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs
@@ -34,7 +34,6 @@ using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenSim.Server.Base;
using OpenMetaverse;
diff --git a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
index 252f7a1..30a73a4 100644
--- a/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Land/LandServiceConnector.cs
@@ -34,7 +34,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using Nwc.XmlRpc;
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
index 9e444c4..2cae02d 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServiceConnector.cs
@@ -36,7 +36,6 @@ using System.Text;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 41ebeaf..7238afc 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenSim.Server.Base;
diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
index 2a5df83..f6835b9 100644
--- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
+++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs
@@ -33,7 +33,6 @@ using System.Reflection;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
-using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
--
cgit v1.1