IRequest.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Model.IO;
  7. using Microsoft.AspNetCore.Http;
  8. namespace MediaBrowser.Model.Services
  9. {
  10. public interface IRequest
  11. {
  12. IResponse Response { get; }
  13. /// <summary>
  14. /// The name of the service being called (e.g. Request DTO Name)
  15. /// </summary>
  16. string OperationName { get; set; }
  17. /// <summary>
  18. /// The Verb / HttpMethod or Action for this request
  19. /// </summary>
  20. string Verb { get; }
  21. /// <summary>
  22. /// The Request DTO, after it has been deserialized.
  23. /// </summary>
  24. object Dto { get; set; }
  25. /// <summary>
  26. /// The request ContentType
  27. /// </summary>
  28. string ContentType { get; }
  29. bool IsLocal { get; }
  30. string UserAgent { get; }
  31. /// <summary>
  32. /// The expected Response ContentType for this request
  33. /// </summary>
  34. string ResponseContentType { get; set; }
  35. /// <summary>
  36. /// Attach any data to this request that all filters and services can access.
  37. /// </summary>
  38. Dictionary<string, object> Items { get; }
  39. IHeaderDictionary Headers { get; }
  40. IQueryCollection QueryString { get; }
  41. Task<QueryParamCollection> GetFormData();
  42. string RawUrl { get; }
  43. string AbsoluteUri { get; }
  44. /// <summary>
  45. /// The Remote Ip as reported by X-Forwarded-For, X-Real-IP or Request.UserHostAddress
  46. /// </summary>
  47. string RemoteIp { get; }
  48. /// <summary>
  49. /// The value of the Authorization Header used to send the Api Key, null if not available
  50. /// </summary>
  51. string Authorization { get; }
  52. string[] AcceptTypes { get; }
  53. string PathInfo { get; }
  54. Stream InputStream { get; }
  55. long ContentLength { get; }
  56. /// <summary>
  57. /// Access to the multi-part/formdata files posted on this request
  58. /// </summary>
  59. IHttpFile[] Files { get; }
  60. /// <summary>
  61. /// The value of the Referrer, null if not available
  62. /// </summary>
  63. Uri UrlReferrer { get; }
  64. }
  65. public interface IHttpFile
  66. {
  67. string Name { get; }
  68. string FileName { get; }
  69. long ContentLength { get; }
  70. string ContentType { get; }
  71. Stream InputStream { get; }
  72. }
  73. public interface IRequiresRequest
  74. {
  75. IRequest Request { get; set; }
  76. }
  77. public interface IResponse
  78. {
  79. HttpResponse OriginalResponse { get; }
  80. int StatusCode { get; set; }
  81. string StatusDescription { get; set; }
  82. string ContentType { get; set; }
  83. void AddHeader(string name, string value);
  84. void Redirect(string url);
  85. Stream OutputStream { get; }
  86. Task TransmitFile(string path, long offset, long count, FileShareMode fileShareMode, IFileSystem fileSystem, IStreamHelper streamHelper, CancellationToken cancellationToken);
  87. bool SendChunked { get; set; }
  88. }
  89. }