HTTP2PluginSettings.cs 2.8 KB

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