HTTP2ConnectionSettings.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #if (!UNITY_WEBGL || UNITY_EDITOR) && !BESTHTTP_DISABLE_ALTERNATE_SSL
  2. using System;
  3. namespace Best.HTTP.Hosts.Connections.HTTP2
  4. {
  5. /// <summary>
  6. /// Settings for HTTP/2 connections when the Connect protocol is available.
  7. /// </summary>
  8. public sealed class WebSocketOverHTTP2Settings
  9. {
  10. /// <summary>
  11. /// Set it to false to disable Websocket Over HTTP/2 (RFC 8441). It's true by default.
  12. /// </summary>
  13. public bool EnableWebSocketOverHTTP2 { get; set; } = true;
  14. /// <summary>
  15. /// Set it to disable fallback logic from the Websocket Over HTTP/2 implementation to the 'old' HTTP/1 implementation when it fails to connect.
  16. /// </summary>
  17. public bool EnableImplementationFallback { get; set; } = true;
  18. }
  19. /// <summary>
  20. /// Settings for HTTP/2 connections.
  21. /// </summary>
  22. public sealed class HTTP2ConnectionSettings
  23. {
  24. /// <summary>
  25. /// When set to false, the plugin will not try to use HTTP/2 connections.
  26. /// </summary>
  27. public bool EnableHTTP2Connections = true;
  28. /// <summary>
  29. /// Maximum size of the HPACK header table.
  30. /// </summary>
  31. public UInt32 HeaderTableSize = 4096; // Spec default: 4096
  32. /// <summary>
  33. /// Maximum concurrent http2 stream on http2 connection will allow. Its default value is 128;
  34. /// </summary>
  35. public UInt32 MaxConcurrentStreams = 128; // Spec default: not defined
  36. /// <summary>
  37. /// Initial window size of a http2 stream. Its default value is 65535, can be controlled through the HTTPRequest's DownloadSettings object.
  38. /// </summary>
  39. public UInt32 InitialStreamWindowSize = UInt16.MaxValue; // Spec default: 65535
  40. /// <summary>
  41. /// Global window size of a http/2 connection. Its default value is the maximum possible value on 31 bits.
  42. /// </summary>
  43. public UInt32 InitialConnectionWindowSize = HTTP2ContentConsumer.MaxValueFor31Bits; // Spec default: 65535
  44. /// <summary>
  45. /// Maximum size of a http2 frame.
  46. /// </summary>
  47. public UInt32 MaxFrameSize = 16384; // 16384 spec def.
  48. /// <summary>
  49. /// Not used.
  50. /// </summary>
  51. public UInt32 MaxHeaderListSize = UInt32.MaxValue; // Spec default: infinite
  52. /// <summary>
  53. /// With HTTP/2 only one connection will be open so we can keep it open longer as we hope it will be reused more.
  54. /// </summary>
  55. public TimeSpan MaxIdleTime = TimeSpan.FromSeconds(120);
  56. /// <summary>
  57. /// Time between two ping messages.
  58. /// </summary>
  59. public TimeSpan PingFrequency = TimeSpan.FromSeconds(5);
  60. /// <summary>
  61. /// Timeout to receive a ping acknowledgement from the server. If no ack reveived in this time the connection will be treated as broken.
  62. /// </summary>
  63. public TimeSpan Timeout = TimeSpan.FromSeconds(3);
  64. /// <summary>
  65. /// Set to true to enable RFC 8441 "Bootstrapping WebSockets with HTTP/2" (https://tools.ietf.org/html/rfc8441).
  66. /// </summary>
  67. public bool EnableConnectProtocol = false;
  68. /// <summary>
  69. /// Settings for WebSockets over HTTP/2 (RFC 8441)
  70. /// </summary>
  71. public WebSocketOverHTTP2Settings WebSocketOverHTTP2Settings = new WebSocketOverHTTP2Settings();
  72. }
  73. }
  74. #endif