aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/XmlRpcCS/XmlRpcResponder.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:02:47 +0000
committerAdam Frisby2007-07-11 08:02:47 +0000
commit5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /Common/XmlRpcCS/XmlRpcResponder.cs
parentWho would have known that the only way of specifying utf-8 without preamble, ... (diff)
downloadopensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz
* Wiping trunk in prep for Sugilite
Diffstat (limited to 'Common/XmlRpcCS/XmlRpcResponder.cs')
-rw-r--r--Common/XmlRpcCS/XmlRpcResponder.cs127
1 files changed, 0 insertions, 127 deletions
diff --git a/Common/XmlRpcCS/XmlRpcResponder.cs b/Common/XmlRpcCS/XmlRpcResponder.cs
deleted file mode 100644
index 05377a2..0000000
--- a/Common/XmlRpcCS/XmlRpcResponder.cs
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28namespace Nwc.XmlRpc
29{
30 using System;
31 using System.Xml;
32 using System.Net.Sockets;
33 using System.Text;
34
35 /// <summary>The class is a container of the context of an XML-RPC dialog on the server side.</summary>
36 /// <remarks>Instances of this class maintain the context for an individual XML-RPC server
37 /// side dialog. Namely they manage an inbound deserializer and an outbound serializer. </remarks>
38 public class XmlRpcResponder
39 {
40 private XmlRpcRequestDeserializer _deserializer = new XmlRpcRequestDeserializer();
41 private XmlRpcResponseSerializer _serializer = new XmlRpcResponseSerializer();
42 private XmlRpcServer _server;
43 private TcpClient _client;
44 private SimpleHttpRequest _httpReq;
45
46 /// <summary>The SimpleHttpRequest based on the TcpClient.</summary>
47 public SimpleHttpRequest HttpReq
48 {
49 get { return _httpReq; }
50 }
51
52 /// <summary>Basic constructor.</summary>
53 /// <param name="server">XmlRpcServer that this XmlRpcResponder services.</param>
54 /// <param name="client">TcpClient with the connection.</param>
55 public XmlRpcResponder(XmlRpcServer server, TcpClient client)
56 {
57 _server = server;
58 _client = client;
59 _httpReq = new SimpleHttpRequest(_client);
60 }
61
62 /// <summary>Call close to insure proper shutdown.</summary>
63 ~XmlRpcResponder()
64 {
65 Close();
66 }
67
68 ///<summary>Respond using this responders HttpReq.</summary>
69 public void Respond()
70 {
71 Respond(HttpReq);
72 }
73
74 /// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
75 /// <remarks>This method deserializes the XML-RPC request, invokes the
76 /// described method, serializes the response (or fault) and sends the XML-RPC response
77 /// back as a valid HTTP page.
78 /// </remarks>
79 /// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
80 public void Respond(SimpleHttpRequest httpReq)
81 {
82 XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
83 XmlRpcResponse xmlRpcResp = new XmlRpcResponse();
84
85 try
86 {
87 xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
88 }
89 catch (XmlRpcException e)
90 {
91 xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
92 }
93 catch (Exception e2)
94 {
95 xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
96 XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
97 }
98
99 if (Logger.Delegate != null)
100 Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);
101
102 XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
103 httpReq.Output.Flush();
104
105 XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
106 _serializer.Serialize(xml, xmlRpcResp);
107 xml.Flush();
108 httpReq.Output.Flush();
109 }
110
111 ///<summary>Close all contained resources, both the HttpReq and client.</summary>
112 public void Close()
113 {
114 if (_httpReq != null)
115 {
116 _httpReq.Close();
117 _httpReq = null;
118 }
119
120 if (_client != null)
121 {
122 _client.Close();
123 _client = null;
124 }
125 }
126 }
127}