< Summary

Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
.ctor()100%11100%
TryParseValue(...)100%44100%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Net.Http/src/System/Net/Http/Headers/CookieHeaderParser.cs

#LineLine coverage
 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
 4using System.Diagnostics;
 5using System.Diagnostics.CodeAnalysis;
 6
 7namespace System.Net.Http.Headers
 8{
 9    internal sealed class CookieHeaderParser : HttpHeaderParser
 10    {
 111        internal static readonly CookieHeaderParser Parser = new CookieHeaderParser();
 12
 13        // According to RFC 6265 Section 4.2 multiple cookies have
 14        // to be concatenated using "; " as the separator.
 15        private CookieHeaderParser()
 116            : base(true, "; ")
 117        {
 118        }
 19
 20        public override bool TryParseValue(string? value, object? storeValue, ref int index, [NotNullWhen(true)] out obj
 5721        {
 5722            Debug.Assert(index == 0);
 23
 24            // Some headers support empty/null values. This one doesn't.
 5725            if (string.IsNullOrEmpty(value) || HttpRuleParser.ContainsNewLineOrNull(value))
 3026            {
 3027                parsedValue = null;
 3028                return false;
 29            }
 30
 2731            parsedValue = value;
 2732            index = value.Length;
 33
 2734            return true;
 5735        }
 36    }
 37}
 38