Response.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. namespace MediaBrowser.Controller.Net
  6. {
  7. public class Response
  8. {
  9. protected RequestContext RequestContext { get; private set; }
  10. public Response(RequestContext ctx)
  11. {
  12. RequestContext = ctx;
  13. WriteStream = s => { };
  14. StatusCode = 200;
  15. Headers = new Dictionary<string, string>();
  16. CacheDuration = TimeSpan.FromTicks(0);
  17. ContentType = "text/html";
  18. }
  19. public int StatusCode { get; set; }
  20. public string ContentType { get; set; }
  21. public IDictionary<string, string> Headers { get; set; }
  22. public TimeSpan CacheDuration { get; set; }
  23. public Action<Stream> WriteStream { get; set; }
  24. }
  25. /*public class ByteResponse : Response
  26. {
  27. public ByteResponse(byte[] bytes)
  28. {
  29. WriteStream = async s =>
  30. {
  31. await s.WriteAsync(bytes, 0, bytes.Length);
  32. s.Close();
  33. };
  34. }
  35. }
  36. public class StringResponse : ByteResponse
  37. {
  38. public StringResponse(string message)
  39. : base(Encoding.UTF8.GetBytes(message))
  40. {
  41. }
  42. }*/
  43. }