| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Net.WebSockets |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Options to enable per-message deflate compression for <seealso cref="WebSocket" />. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// Although the WebSocket spec allows window bits from 8 to 15, the current implementation doesn't support 8 bits. |
| | | 11 | | /// </remarks> |
| | | 12 | | public sealed class WebSocketDeflateOptions |
| | | 13 | | { |
| | 2025 | 14 | | private int _clientMaxWindowBits = WebSocketValidate.MaxDeflateWindowBits; |
| | 2025 | 15 | | private int _serverMaxWindowBits = WebSocketValidate.MaxDeflateWindowBits; |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// This parameter indicates the base-2 logarithm for the LZ77 sliding window size used by |
| | | 19 | | /// the client to compress messages and by the server to decompress them. |
| | | 20 | | /// Must be a value between 9 and 15. The default is 15. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <remarks>https://tools.ietf.org/html/rfc7692#section-7.1.2.2</remarks> |
| | | 23 | | public int ClientMaxWindowBits |
| | | 24 | | { |
| | 2025 | 25 | | get => _clientMaxWindowBits; |
| | | 26 | | set |
| | 0 | 27 | | { |
| | 0 | 28 | | if (value < WebSocketValidate.MinDeflateWindowBits || value > WebSocketValidate.MaxDeflateWindowBits) |
| | 0 | 29 | | { |
| | 0 | 30 | | throw new ArgumentOutOfRangeException(nameof(ClientMaxWindowBits), value, |
| | 0 | 31 | | SR.Format(SR.net_WebSockets_ArgumentOutOfRange, WebSocketValidate.MinDeflateWindowBits, WebSocke |
| | | 32 | | } |
| | 0 | 33 | | _clientMaxWindowBits = value; |
| | 0 | 34 | | } |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// When true the client-side of the connection indicates that it will persist the deflate context across messag |
| | | 39 | | /// The default is true. |
| | | 40 | | /// </summary> |
| | | 41 | | /// <remarks>https://tools.ietf.org/html/rfc7692#section-7.1.1.2</remarks> |
| | 4050 | 42 | | public bool ClientContextTakeover { get; set; } = true; |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// This parameter indicates the base-2 logarithm for the LZ77 sliding window size used by |
| | | 46 | | /// the server to compress messages and by the client to decompress them. |
| | | 47 | | /// Must be a value between 9 and 15. The default is 15. |
| | | 48 | | /// </summary> |
| | | 49 | | /// <remarks>https://tools.ietf.org/html/rfc7692#section-7.1.2.1</remarks> |
| | | 50 | | public int ServerMaxWindowBits |
| | | 51 | | { |
| | 2025 | 52 | | get => _serverMaxWindowBits; |
| | | 53 | | set |
| | 0 | 54 | | { |
| | 0 | 55 | | if (value < WebSocketValidate.MinDeflateWindowBits || value > WebSocketValidate.MaxDeflateWindowBits) |
| | 0 | 56 | | { |
| | 0 | 57 | | throw new ArgumentOutOfRangeException(nameof(ServerMaxWindowBits), value, |
| | 0 | 58 | | SR.Format(SR.net_WebSockets_ArgumentOutOfRange, WebSocketValidate.MinDeflateWindowBits, WebSocke |
| | | 59 | | } |
| | 0 | 60 | | _serverMaxWindowBits = value; |
| | 0 | 61 | | } |
| | | 62 | | } |
| | | 63 | | |
| | | 64 | | /// <summary> |
| | | 65 | | /// When true the server-side of the connection indicates that it will persist the deflate context across messag |
| | | 66 | | /// The default is true. |
| | | 67 | | /// </summary> |
| | | 68 | | /// <remarks>https://tools.ietf.org/html/rfc7692#section-7.1.1.1</remarks> |
| | 4050 | 69 | | public bool ServerContextTakeover { get; set; } = true; |
| | | 70 | | } |
| | | 71 | | } |
| | | 72 | | |