IHttpRequests.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 System;
  28. using System.Collections.Generic;
  29. using OpenMetaverse;
  30. namespace OpenSim.Region.Framework.Interfaces
  31. {
  32. public enum HttpRequestConstants
  33. {
  34. HTTP_METHOD = 0,
  35. HTTP_MIMETYPE = 1,
  36. HTTP_BODY_MAXLENGTH = 2,
  37. HTTP_VERIFY_CERT = 3,
  38. HTTP_VERBOSE_THROTTLE = 4,
  39. HTTP_CUSTOM_HEADER = 5,
  40. HTTP_PRAGMA_NO_CACHE = 6
  41. }
  42. /// <summary>
  43. /// The initial status of the request before it is placed on the wire.
  44. /// </summary>
  45. /// <remarks>
  46. /// The request may still fail later on, in which case the normal HTTP status is set.
  47. /// </remarks>
  48. [Flags]
  49. public enum HttpInitialRequestStatus
  50. {
  51. OK = 1,
  52. DISALLOWED_BY_FILTER = 2
  53. }
  54. public interface IHttpRequestModule
  55. {
  56. UUID MakeHttpRequest(string url, string parameters, string body);
  57. /// <summary>
  58. /// Starts the http request.
  59. /// </summary>
  60. /// <remarks>
  61. /// This is carried out asynchronously unless it fails initial checks. Results are fetched by the script engine
  62. /// HTTP requests module to be distributed back to scripts via a script event.
  63. /// </remarks>
  64. /// <returns>The ID of the request. If the requested could not be performed then this is UUID.Zero</returns>
  65. /// <param name="localID">Local ID of the object containing the script making the request.</param>
  66. /// <param name="itemID">Item ID of the script making the request.</param>
  67. /// <param name="url">Url to request.</param>
  68. /// <param name="parameters">LSL parameters for the request.</param>
  69. /// <param name="headers">Extra headers for the request.</param>
  70. /// <param name="body">Body of the request.</param>
  71. /// <param name="status">
  72. /// Initial status of the request. If OK then the request is actually made to the URL. Subsequent status is
  73. /// then returned via IServiceRequest when the response is asynchronously fetched.
  74. /// </param>
  75. UUID StartHttpRequest(
  76. uint localID, UUID itemID, string url, List<string> parameters, Dictionary<string, string> headers, string body,
  77. out HttpInitialRequestStatus status);
  78. /// <summary>
  79. /// Stop and remove all http requests for the given script.
  80. /// </summary>
  81. /// <param name='id'></param>
  82. void StopHttpRequest(uint m_localID, UUID m_itemID);
  83. IServiceRequest GetNextCompletedRequest();
  84. void RemoveCompletedRequest(UUID id);
  85. }
  86. }