1
0

IHttpServer.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. using Nwc.XmlRpc;
  28. namespace OpenSim.Framework.Servers.HttpServer
  29. {
  30. /// <summary>
  31. /// Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.)
  32. /// for given URLs.
  33. /// </summary>
  34. public interface IHttpServer
  35. {
  36. uint SSLPort { get; }
  37. string SSLCommonName { get; }
  38. uint Port { get; }
  39. bool UseSSL { get; }
  40. // Note that the agent string is provided simply to differentiate
  41. // the handlers - it is NOT required to be an actual agent header
  42. // value.
  43. bool AddAgentHandler(string agent, IHttpAgentHandler handler);
  44. /// <summary>
  45. /// Add a handler for an HTTP request
  46. /// </summary>
  47. ///
  48. /// This handler can actually be invoked either as
  49. ///
  50. /// http://<hostname>:<port>/?method=<methodName>
  51. ///
  52. /// or
  53. ///
  54. /// http://<hostname>:<port><method>
  55. ///
  56. /// if the method name starts with a slash. For example, AddHTTPHandler("/object/", ...) on a standalone region
  57. /// server will register a handler that can be invoked with either
  58. ///
  59. /// http://localhost:9000/?method=/object/
  60. ///
  61. /// or
  62. ///
  63. /// http://localhost:9000/object/
  64. ///
  65. /// <param name="methodName"></param>
  66. /// <param name="handler"></param>
  67. /// <returns>
  68. /// true if the handler was successfully registered, false if a handler with the same name already existed.
  69. /// </returns>
  70. bool AddHTTPHandler(string methodName, GenericHTTPMethod handler);
  71. bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args);
  72. /// <summary>
  73. /// Adds a LLSD handler, yay.
  74. /// </summary>
  75. /// <param name="path">/resource/ path</param>
  76. /// <param name="handler">handle the LLSD response</param>
  77. /// <returns></returns>
  78. bool AddLLSDHandler(string path, LLSDMethod handler);
  79. /// <summary>
  80. /// Add a stream handler to the http server. If the handler already exists, then nothing happens.
  81. /// </summary>
  82. /// <param name="handler"></param>
  83. void AddStreamHandler(IRequestHandler handler);
  84. bool AddXmlRPCHandler(string method, XmlRpcMethod handler);
  85. bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive);
  86. /// <summary>
  87. /// Gets the XML RPC handler for given method name
  88. /// </summary>
  89. /// <param name="method">Name of the method</param>
  90. /// <returns>Returns null if not found</returns>
  91. XmlRpcMethod GetXmlRPCHandler(string method);
  92. bool SetDefaultLLSDHandler(DefaultLLSDMethod handler);
  93. /// <summary>
  94. /// Remove the agent if it is registered.
  95. /// </summary>
  96. /// <param name="agent"></param>
  97. /// <param name="handler"></param>
  98. /// <returns></returns>
  99. bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
  100. /// <summary>
  101. /// Remove an HTTP handler
  102. /// </summary>
  103. /// <param name="httpMethod"></param>
  104. /// <param name="path"></param>
  105. void RemoveHTTPHandler(string httpMethod, string path);
  106. void RemovePollServiceHTTPHandler(string httpMethod, string path);
  107. bool RemoveLLSDHandler(string path, LLSDMethod handler);
  108. void RemoveStreamHandler(string httpMethod, string path);
  109. void RemoveXmlRPCHandler(string method);
  110. string GetHTTP404(string host);
  111. string GetHTTP500();
  112. }
  113. }