IRequest.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Net;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using MediaBrowser.Model.IO;
  8. namespace MediaBrowser.Model.Services
  9. {
  10. public interface IRequest
  11. {
  12. /// <summary>
  13. /// The underlying ASP.NET or HttpListener HttpRequest
  14. /// </summary>
  15. object OriginalRequest { get; }
  16. IResponse Response { get; }
  17. /// <summary>
  18. /// The name of the service being called (e.g. Request DTO Name)
  19. /// </summary>
  20. string OperationName { get; set; }
  21. /// <summary>
  22. /// The Verb / HttpMethod or Action for this request
  23. /// </summary>
  24. string Verb { get; }
  25. /// <summary>
  26. /// The Request DTO, after it has been deserialized.
  27. /// </summary>
  28. object Dto { get; set; }
  29. /// <summary>
  30. /// The request ContentType
  31. /// </summary>
  32. string ContentType { get; }
  33. bool IsLocal { get; }
  34. string UserAgent { get; }
  35. IDictionary<string, Cookie> Cookies { get; }
  36. /// <summary>
  37. /// The expected Response ContentType for this request
  38. /// </summary>
  39. string ResponseContentType { get; set; }
  40. /// <summary>
  41. /// Attach any data to this request that all filters and services can access.
  42. /// </summary>
  43. Dictionary<string, object> Items { get; }
  44. QueryParamCollection Headers { get; }
  45. QueryParamCollection QueryString { get; }
  46. Task<QueryParamCollection> GetFormData();
  47. string RawUrl { get; }
  48. string AbsoluteUri { get; }
  49. /// <summary>
  50. /// The Remote Ip as reported by Request.UserHostAddress
  51. /// </summary>
  52. string UserHostAddress { get; }
  53. /// <summary>
  54. /// The Remote Ip as reported by X-Forwarded-For, X-Real-IP or Request.UserHostAddress
  55. /// </summary>
  56. string RemoteIp { get; }
  57. /// <summary>
  58. /// The value of the Authorization Header used to send the Api Key, null if not available
  59. /// </summary>
  60. string Authorization { get; }
  61. /// <summary>
  62. /// e.g. is https or not
  63. /// </summary>
  64. bool IsSecureConnection { get; }
  65. string[] AcceptTypes { get; }
  66. string PathInfo { get; }
  67. Stream InputStream { get; }
  68. long ContentLength { get; }
  69. /// <summary>
  70. /// Access to the multi-part/formdata files posted on this request
  71. /// </summary>
  72. IHttpFile[] Files { get; }
  73. /// <summary>
  74. /// The value of the Referrer, null if not available
  75. /// </summary>
  76. Uri UrlReferrer { get; }
  77. }
  78. public interface IHttpFile
  79. {
  80. string Name { get; }
  81. string FileName { get; }
  82. long ContentLength { get; }
  83. string ContentType { get; }
  84. Stream InputStream { get; }
  85. }
  86. public interface IRequiresRequest
  87. {
  88. IRequest Request { get; set; }
  89. }
  90. public interface IResponse
  91. {
  92. IRequest Request { get; }
  93. int StatusCode { get; set; }
  94. string StatusDescription { get; set; }
  95. string ContentType { get; set; }
  96. void AddHeader(string name, string value);
  97. string GetHeader(string name);
  98. void Redirect(string url);
  99. Stream OutputStream { get; }
  100. /// <summary>
  101. /// Signal that this response has been handled and no more processing should be done.
  102. /// When used in a request or response filter, no more filters or processing is done on this request.
  103. /// </summary>
  104. void Close();
  105. /// <summary>
  106. /// Gets a value indicating whether this instance is closed.
  107. /// </summary>
  108. bool IsClosed { get; }
  109. void SetContentLength(long contentLength);
  110. //Add Metadata to Response
  111. Dictionary<string, object> Items { get; }
  112. QueryParamCollection Headers { get; }
  113. Task TransmitFile(string path, long offset, long count, FileShareMode fileShareMode, CancellationToken cancellationToken);
  114. bool SendChunked { get; set; }
  115. }
  116. }