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 -------------
3 files changed, 445 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/Framework/Servers')
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;
- }
- }
-}
--
cgit v1.1
From ccc26f74436f0e3069587efd96497053e4129c3c Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 20 Apr 2011 01:02:40 +0100
Subject: Get Viewer 2 voice working with OpenSim.
See http://opensimulator.org/mantis/view.php?id=5336
It turns out that viewer 2 was upset by the lack of a response to viv_watcher.php. This would send it into a continuous login loop.
Viewer 1 was quite happy to ignore the lack of response.
This commit puts in the bare minimum 'OK' message in response to viv_watcher.php. This allows viewer 2 voice to connect and appears to work.
However, at some point we need to fill out the watcher response, whatever that is.
---
OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index ccec9b7..ba89e21 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -430,7 +430,7 @@ namespace OpenSim.Framework.Servers.HttpServer
string path = request.RawUrl;
string handlerKey = GetHandlerKey(request.HttpMethod, path);
- //m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path);
+// m_log.DebugFormat("[BASE HTTP SERVER]: Handling {0} request for {1}", request.HttpMethod, path);
if (TryGetStreamHandler(handlerKey, out requestHandler))
{
--
cgit v1.1