You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. #if !NET20
  2. using System.Collections.Generic;
  3. using System;
  4. namespace Apewer.WebSocket
  5. {
  6. internal class HttpRequest
  7. {
  8. private readonly IDictionary<string, string> _headers = new Dictionary<string, string>(System.StringComparer.InvariantCultureIgnoreCase);
  9. public string Method { get; set; }
  10. public string Path { get; set; }
  11. public string Body { get; set; }
  12. public string Scheme { get; set; }
  13. public byte[] Bytes { get; set; }
  14. public string this[string name]
  15. {
  16. get
  17. {
  18. string value;
  19. return _headers.TryGetValue(name, out value) ? value : default(string);
  20. }
  21. }
  22. public IDictionary<string, string> Headers
  23. {
  24. get
  25. {
  26. return _headers;
  27. }
  28. }
  29. public string[] SubProtocols {
  30. get
  31. {
  32. string value;
  33. return _headers.TryGetValue("Sec-WebSocket-Protocol", out value)
  34. ? value.Split(new []{',', ' '}, StringSplitOptions.RemoveEmptyEntries)
  35. : new string[0];
  36. }
  37. }
  38. }
  39. }
  40. #endif