< Summary

Information
Class: System.Net.Http.CookieHelper
Assembly: System.Net.Http
File(s): D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CookieHelper.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ProcessReceivedCookies(...)0%880%

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\CookieHelper.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.Collections.Generic;
 5using System.Diagnostics;
 6using System.Net.Http.Headers;
 7
 8namespace System.Net.Http
 9{
 10    internal static class CookieHelper
 11    {
 12        public static void ProcessReceivedCookies(HttpResponseMessage response, CookieContainer cookieContainer)
 013        {
 014            if (response.Headers.TryGetValues(KnownHeaders.SetCookie.Descriptor, out IEnumerable<string>? values))
 015            {
 16                // The header values are always a string[]
 017                var valuesArray = (string[])values;
 018                Debug.Assert(valuesArray.Length > 0, "No values for header??");
 019                Debug.Assert(response.RequestMessage != null && response.RequestMessage.RequestUri != null);
 20
 021                Uri requestUri = response.RequestMessage.RequestUri;
 022                for (int i = 0; i < valuesArray.Length; i++)
 023                {
 24                    try
 025                    {
 026                        cookieContainer.SetCookies(requestUri, valuesArray[i]);
 027                    }
 028                    catch (CookieException)
 029                    {
 30                        // Ignore invalid Set-Cookie header and continue processing.
 031                        if (NetEventSource.Log.IsEnabled())
 032                        {
 033                            NetEventSource.Error(response, $"Invalid Set-Cookie '{valuesArray[i]}' ignored.");
 034                        }
 035                    }
 036                }
 037            }
 038        }
 39    }
 40}