IRequest.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. /// <summary>
  36. /// The expected Response ContentType for this request
  37. /// </summary>
  38. string ResponseContentType { get; set; }
  39. /// <summary>
  40. /// Attach any data to this request that all filters and services can access.
  41. /// </summary>
  42. Dictionary<string, object> Items { get; }
  43. QueryParamCollection Headers { get; }
  44. QueryParamCollection QueryString { get; }
  45. Task<QueryParamCollection> GetFormData();
  46. string RawUrl { get; }
  47. string AbsoluteUri { get; }
  48. /// <summary>
  49. /// The Remote Ip as reported by X-Forwarded-For, X-Real-IP or Request.UserHostAddress
  50. /// </summary>
  51. string RemoteIp { get; }
  52. /// <summary>
  53. /// The value of the Authorization Header used to send the Api Key, null if not available
  54. /// </summary>
  55. string Authorization { get; }
  56. string[] AcceptTypes { get; }
  57. string PathInfo { get; }
  58. Stream InputStream { get; }
  59. long ContentLength { get; }
  60. /// <summary>
  61. /// Access to the multi-part/formdata files posted on this request
  62. /// </summary>
  63. IHttpFile[] Files { get; }
  64. /// <summary>
  65. /// The value of the Referrer, null if not available
  66. /// </summary>
  67. Uri UrlReferrer { get; }
  68. }
  69. public interface IHttpFile
  70. {
  71. string Name { get; }
  72. string FileName { get; }
  73. long ContentLength { get; }
  74. string ContentType { get; }
  75. Stream InputStream { get; }
  76. }
  77. public interface IRequiresRequest
  78. {
  79. IRequest Request { get; set; }
  80. }
  81. public interface IResponse
  82. {
  83. IRequest Request { get; }
  84. int StatusCode { get; set; }
  85. string StatusDescription { get; set; }
  86. string ContentType { get; set; }
  87. void AddHeader(string name, string value);
  88. string GetHeader(string name);
  89. void Redirect(string url);
  90. Stream OutputStream { get; }
  91. /// <summary>
  92. /// Signal that this response has been handled and no more processing should be done.
  93. /// When used in a request or response filter, no more filters or processing is done on this request.
  94. /// </summary>
  95. void Close();
  96. /// <summary>
  97. /// Gets a value indicating whether this instance is closed.
  98. /// </summary>
  99. bool IsClosed { get; }
  100. //Add Metadata to Response
  101. Dictionary<string, object> Items { get; }
  102. QueryParamCollection Headers { get; }
  103. Task TransmitFile(string path, long offset, long count, FileShareMode fileShareMode, IFileSystem fileSystem, IStreamHelper streamHelper, CancellationToken cancellationToken);
  104. bool SendChunked { get; set; }
  105. }
  106. }