aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer/Interfaces
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpAgentHandler.cs35
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs150
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs59
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs132
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs91
5 files changed, 467 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpAgentHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpAgentHandler.cs
new file mode 100644
index 0000000..7078895
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpAgentHandler.cs
@@ -0,0 +1,35 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 OpenSim.Framework.Servers.HttpServer
29{
30 public interface IHttpAgentHandler
31 {
32 bool Handle(OSHttpRequest req, OSHttpResponse resp);
33 bool Match(OSHttpRequest req, OSHttpResponse resp);
34 }
35}
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
new file mode 100644
index 0000000..d162bc1
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
@@ -0,0 +1,150 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using Nwc.XmlRpc;
29
30namespace OpenSim.Framework.Servers.HttpServer
31{
32 /// <summary>
33 /// Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.)
34 /// for given URLs.
35 /// </summary>
36 public interface IHttpServer
37 {
38 uint SSLPort { get; }
39 string SSLCommonName { get; }
40
41 uint Port { get; }
42 bool UseSSL { get; }
43
44// // Note that the agent string is provided simply to differentiate
45// // the handlers - it is NOT required to be an actual agent header
46// // value.
47// bool AddAgentHandler(string agent, IHttpAgentHandler handler);
48
49 /// <summary>
50 /// Add a handler for an HTTP request.
51 /// </summary>
52 /// <remarks>
53 /// This handler can actually be invoked either as
54 ///
55 /// http://<hostname>:<port>/?method=<methodName>
56 ///
57 /// or
58 ///
59 /// http://<hostname>:<port><method>
60 ///
61 /// if the method name starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
62 /// server will register a handler that can be invoked with either
63 ///
64 /// http://localhost:9000/?method=/object/
65 ///
66 /// or
67 ///
68 /// http://localhost:9000/object/
69 ///
70 /// In addition, the handler invoked by the HTTP server for any request is the one when best matches the request
71 /// URI. So if a handler for "/myapp/" is registered and a request for "/myapp/page" is received, then
72 /// the "/myapp/" handler is invoked if no "/myapp/page" handler exists.
73 /// </remarks>
74 /// <param name="methodName"></param>
75 /// <param name="handler"></param>
76 /// <returns>
77 /// true if the handler was successfully registered, false if a handler with the same name already existed.
78 /// </returns>
79 bool AddHTTPHandler(string methodName, GenericHTTPMethod handler);
80
81 bool AddPollServiceHTTPHandler(string methodName, PollServiceEventArgs args);
82
83 /// <summary>
84 /// Adds a LLSD handler, yay.
85 /// </summary>
86 /// <param name="path">/resource/ path</param>
87 /// <param name="handler">handle the LLSD response</param>
88 /// <returns></returns>
89 bool AddLLSDHandler(string path, LLSDMethod handler);
90
91 /// <summary>
92 /// Add a stream handler to the http server. If the handler already exists, then nothing happens.
93 /// </summary>
94 /// <param name="handler"></param>
95 void AddStreamHandler(IRequestHandler handler);
96
97 bool AddXmlRPCHandler(string method, XmlRpcMethod handler);
98 bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive);
99
100 bool AddJsonRPCHandler(string method, JsonRPCMethod handler);
101
102 /// <summary>
103 /// Websocket HTTP server handlers.
104 /// </summary>
105 /// <param name="servicepath"></param>
106 /// <param name="handler"></param>
107 void AddWebSocketHandler(string servicepath, BaseHttpServer.WebSocketRequestDelegate handler);
108
109
110 void RemoveWebSocketHandler(string servicepath);
111
112 /// <summary>
113 /// Gets the XML RPC handler for given method name
114 /// </summary>
115 /// <param name="method">Name of the method</param>
116 /// <returns>Returns null if not found</returns>
117 XmlRpcMethod GetXmlRPCHandler(string method);
118
119 bool SetDefaultLLSDHandler(DefaultLLSDMethod handler);
120
121// /// <summary>
122// /// Remove the agent if it is registered.
123// /// </summary>
124// /// <param name="agent"></param>
125// /// <param name="handler"></param>
126// /// <returns></returns>
127// bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
128
129 /// <summary>
130 /// Remove an HTTP handler
131 /// </summary>
132 /// <param name="httpMethod"></param>
133 /// <param name="path"></param>
134 void RemoveHTTPHandler(string httpMethod, string path);
135
136 void RemovePollServiceHTTPHandler(string httpMethod, string path);
137
138 bool RemoveLLSDHandler(string path, LLSDMethod handler);
139
140 void RemoveStreamHandler(string httpMethod, string path);
141
142 void RemoveXmlRPCHandler(string method);
143
144 void RemoveJsonRPCHandler(string method);
145
146 string GetHTTP404(string host);
147
148 string GetHTTP500();
149 }
150}
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs
new file mode 100644
index 0000000..caf0edd
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpRequest.cs
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.IO;
32using System.Net;
33using System.Text;
34using System.Web;
35
36namespace OpenSim.Framework.Servers.HttpServer
37{
38 public interface IOSHttpRequest
39 {
40 string[] AcceptTypes { get; }
41 Encoding ContentEncoding { get; }
42 long ContentLength { get; }
43 long ContentLength64 { get; }
44 string ContentType { get; }
45 HttpCookieCollection Cookies { get; }
46 bool HasEntityBody { get; }
47 NameValueCollection Headers { get; }
48 string HttpMethod { get; }
49 Stream InputStream { get; }
50 bool IsSecured { get; }
51 bool KeepAlive { get; }
52 NameValueCollection QueryString { get; }
53 Hashtable Query { get; }
54 string RawUrl { get; }
55 IPEndPoint RemoteIPEndPoint { get; }
56 Uri Url { get; }
57 string UserAgent { get; }
58 }
59} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs
new file mode 100644
index 0000000..f61b090
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IOSHttpResponse.cs
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Specialized;
31using System.IO;
32using System.Net;
33using System.Text;
34using System.Web;
35
36namespace OpenSim.Framework.Servers.HttpServer
37{
38 public interface IOSHttpResponse
39 {
40 /// <summary>
41 /// Content type property.
42 /// </summary>
43 /// <remarks>
44 /// Setting this property will also set IsContentTypeSet to
45 /// true.
46 /// </remarks>
47 string ContentType { get; set; }
48
49 /// <summary>
50 /// Boolean property indicating whether the content type
51 /// property actively has been set.
52 /// </summary>
53 /// <remarks>
54 /// IsContentTypeSet will go away together with .NET base.
55 /// </remarks>
56 // public bool IsContentTypeSet
57 // {
58 // get { return _contentTypeSet; }
59 // }
60 // private bool _contentTypeSet;
61
62 /// <summary>
63 /// Length of the body content; 0 if there is no body.
64 /// </summary>
65 long ContentLength { get; set; }
66
67 /// <summary>
68 /// Alias for ContentLength.
69 /// </summary>
70 long ContentLength64 { get; set; }
71
72 /// <summary>
73 /// Encoding of the body content.
74 /// </summary>
75 Encoding ContentEncoding { get; set; }
76
77 bool KeepAlive { get; set; }
78
79 /// <summary>
80 /// Get or set the keep alive timeout property (default is
81 /// 20). Setting this to 0 also disables KeepAlive. Setting
82 /// this to something else but 0 also enable KeepAlive.
83 /// </summary>
84 int KeepAliveTimeout { get; set; }
85
86 /// <summary>
87 /// Return the output stream feeding the body.
88 /// </summary>
89 /// <remarks>
90 /// On its way out...
91 /// </remarks>
92 Stream OutputStream { get; }
93
94 string ProtocolVersion { get; set; }
95
96 /// <summary>
97 /// Return the output stream feeding the body.
98 /// </summary>
99 Stream Body { get; }
100
101 /// <summary>
102 /// Set a redirct location.
103 /// </summary>
104 string RedirectLocation { set; }
105
106 /// <summary>
107 /// Chunk transfers.
108 /// </summary>
109 bool SendChunked { get; set; }
110
111 /// <summary>
112 /// HTTP status code.
113 /// </summary>
114 int StatusCode { get; set; }
115
116 /// <summary>
117 /// HTTP status description.
118 /// </summary>
119 string StatusDescription { get; set; }
120
121 bool ReuseContext { get; set; }
122
123 /// <summary>
124 /// Add a header field and content to the response.
125 /// </summary>
126 /// <param name="key">string containing the header field
127 /// name</param>
128 /// <param name="value">string containing the header field
129 /// value</param>
130 void AddHeader(string key, string value);
131 }
132} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
new file mode 100644
index 0000000..b8541cb
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System.Collections;
29using System.IO;
30
31namespace OpenSim.Framework.Servers.HttpServer
32{
33 public interface IRequestHandler
34 {
35 /// <summary>
36 /// Name for this handler.
37 /// </summary>
38 /// <remarks>
39 /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none
40 /// specified.
41 /// </remarks>
42 string Name { get; }
43
44 /// <summary>
45 /// Description for this handler.
46 /// </summary>
47 /// <remarks>
48 /// Used for diagnostics. The path doesn't always describe what the handler does. Can be null if none
49 /// specified.
50 /// </remarks>
51 string Description { get; }
52
53 // Return response content type
54 string ContentType { get; }
55
56 // Return required http method
57 string HttpMethod { get; }
58
59 // Return path
60 string Path { get; }
61
62 /// <summary>
63 /// Number of requests received by this handler
64 /// </summary>
65 int RequestsReceived { get; }
66
67 /// <summary>
68 /// Number of requests handled.
69 /// </summary>
70 /// <remarks>
71 /// Should be equal to RequestsReceived unless requested are being handled slowly or there is deadlock.
72 /// </remarks>
73 int RequestsHandled { get; }
74 }
75
76 public interface IStreamedRequestHandler : IRequestHandler
77 {
78 // Handle request stream, return byte array
79 byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
80 }
81
82 public interface IStreamHandler : IRequestHandler
83 {
84 void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse);
85 }
86
87 public interface IGenericHTTPHandler : IRequestHandler
88 {
89 Hashtable Handle(string path, Hashtable request);
90 }
91} \ No newline at end of file