| | | 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 | | using System.Diagnostics; |
| | | 5 | | |
| | | 6 | | namespace System.Net.Http.Headers |
| | | 7 | | { |
| | | 8 | | internal sealed class TransferCodingHeaderParser : BaseHeaderParser |
| | | 9 | | { |
| | | 10 | | private readonly Func<TransferCodingHeaderValue> _transferCodingCreator; |
| | | 11 | | |
| | 1 | 12 | | internal static readonly TransferCodingHeaderParser SingleValueParser = |
| | 1 | 13 | | new TransferCodingHeaderParser(false, CreateTransferCoding); |
| | 1 | 14 | | internal static readonly TransferCodingHeaderParser MultipleValueParser = |
| | 1 | 15 | | new TransferCodingHeaderParser(true, CreateTransferCoding); |
| | 1 | 16 | | internal static readonly TransferCodingHeaderParser SingleValueWithQualityParser = |
| | 1 | 17 | | new TransferCodingHeaderParser(false, CreateTransferCodingWithQuality); |
| | 1 | 18 | | internal static readonly TransferCodingHeaderParser MultipleValueWithQualityParser = |
| | 1 | 19 | | new TransferCodingHeaderParser(true, CreateTransferCodingWithQuality); |
| | | 20 | | |
| | | 21 | | private TransferCodingHeaderParser(bool supportsMultipleValues, |
| | | 22 | | Func<TransferCodingHeaderValue> transferCodingCreator) |
| | 4 | 23 | | : base(supportsMultipleValues) |
| | 4 | 24 | | { |
| | 4 | 25 | | Debug.Assert(transferCodingCreator != null); |
| | | 26 | | |
| | 4 | 27 | | _transferCodingCreator = transferCodingCreator; |
| | 4 | 28 | | } |
| | | 29 | | |
| | | 30 | | protected override int GetParsedValueLength(string value, int startIndex, object? storeValue, |
| | | 31 | | out object? parsedValue) |
| | 358822 | 32 | | { |
| | 358822 | 33 | | int resultLength = TransferCodingHeaderValue.GetTransferCodingLength(value, startIndex, |
| | 358822 | 34 | | _transferCodingCreator, out TransferCodingHeaderValue? temp); |
| | | 35 | | |
| | 358822 | 36 | | parsedValue = temp; |
| | 358822 | 37 | | return resultLength; |
| | 358822 | 38 | | } |
| | | 39 | | |
| | 266222 | 40 | | private static TransferCodingHeaderValue CreateTransferCoding() => new TransferCodingHeaderValue(); |
| | | 41 | | |
| | 92426 | 42 | | private static TransferCodingWithQualityHeaderValue CreateTransferCodingWithQuality() => new TransferCodingWithQ |
| | | 43 | | } |
| | | 44 | | } |