IHttpServer.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. /// </remarks>
  46. /// <param name="methodName"></param>
  47. /// <param name="handler"></param>
  48. /// <returns>
  49. /// true if the handler was successfully registered, false if a handler with the same name already existed.
  50. /// </returns>
  51. bool AddHTTPHandler(string methodName, GenericHTTPMethod handler);
  52. bool AddPollServiceHTTPHandler(string uripath, PollServiceEventArgs args);
  53. bool AddPollServiceHTTPHandler(PollServiceEventArgs args);
  54. bool AddPollServiceHTTPHandlerVarPath(PollServiceEventArgs args);
  55. void RemovePollServiceHTTPHandler(string url, string path);
  56. void RemovePollServiceHTTPHandler(string path);
  57. /// <summary>
  58. /// Adds a LLSD handler, yay.
  59. /// </summary>
  60. /// <param name="path">/resource/ path</param>
  61. /// <param name="handler">handle the LLSD response</param>
  62. /// <returns></returns>
  63. bool AddLLSDHandler(string path, LLSDMethod handler);
  64. /// <summary>
  65. /// Add a stream handler to the http server. If the handler already exists, then nothing happens.
  66. /// </summary>
  67. /// <param name="handler"></param>
  68. void AddStreamHandler(IRequestHandler handler);
  69. void AddSimpleStreamHandler(ISimpleStreamHandler handler, bool varPath = false);
  70. bool AddXmlRPCHandler(string method, XmlRpcMethod handler);
  71. bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive);
  72. bool AddJsonRPCHandler(string method, JsonRPCMethod handler);
  73. /// <summary>
  74. /// Websocket HTTP server handlers.
  75. /// </summary>
  76. /// <param name="servicepath"></param>
  77. /// <param name="handler"></param>
  78. void AddWebSocketHandler(string servicepath, BaseHttpServer.WebSocketRequestDelegate handler);
  79. void RemoveWebSocketHandler(string servicepath);
  80. /// <summary>
  81. /// Gets the XML RPC handler for given method name
  82. /// </summary>
  83. /// <param name="method">Name of the method</param>
  84. /// <returns>Returns null if not found</returns>
  85. XmlRpcMethod GetXmlRPCHandler(string method);
  86. bool SetDefaultLLSDHandler(DefaultLLSDMethod handler);
  87. // /// <summary>
  88. // /// Remove the agent if it is registered.
  89. // /// </summary>
  90. // /// <param name="agent"></param>
  91. // /// <param name="handler"></param>
  92. // /// <returns></returns>
  93. // bool RemoveAgentHandler(string agent, IHttpAgentHandler handler);
  94. /// <summary>
  95. /// Remove an HTTP handler
  96. /// </summary>
  97. /// <param name="httpMethod"></param>
  98. /// <param name="path"></param>
  99. void RemoveHTTPHandler(string httpMethod, string path);
  100. bool RemoveLLSDHandler(string path, LLSDMethod handler);
  101. void RemoveStreamHandler(string httpMethod, string path);
  102. void RemoveSimpleStreamHandler(string path);
  103. void RemoveXmlRPCHandler(string method);
  104. void RemoveJsonRPCHandler(string method);
  105. string GetHTTP404();
  106. void AddIndexPHPMethodHandler(string key, SimpleStreamMethod sh);
  107. void RemoveIndexPHPMethodHandler(string key);
  108. SimpleStreamMethod TryGetIndexPHPMethodHandler(string key);
  109. }
  110. }