< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 69
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 20
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\HttpUtilities.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
 4namespace System.Net.Http
 5{
 6    internal static partial class HttpUtilities
 7    {
 8        public static string ParseHostNameFromHeader(string hostHeader)
 09        {
 10            // See if we need to trim off a port.
 011            int colonPos = hostHeader.IndexOf(':');
 012            if (colonPos >= 0)
 013            {
 14                // There is colon, which could either be a port separator or a separator in
 15                // an IPv6 address.  See if this is an IPv6 address; if it's not, use everything
 16                // before the colon as the host name, and if it is, use everything before the last
 17                // colon iff the last colon is after the end of the IPv6 address (otherwise it's a
 18                // part of the address).
 019                int ipV6AddressEnd = hostHeader.IndexOf(']');
 020                if (ipV6AddressEnd == -1)
 021                {
 022                    return hostHeader.Substring(0, colonPos);
 23                }
 24                else
 025                {
 026                    colonPos = hostHeader.LastIndexOf(':');
 027                    if (colonPos > ipV6AddressEnd)
 028                    {
 029                        return hostHeader.Substring(0, colonPos);
 30                    }
 031                }
 032            }
 33
 034            return hostHeader;
 035        }
 36    }
 37}

D:\runner\runtime\src\libraries\System.Net.Http\src\System\Net\Http\SocketsHttpHandler\HttpUtilities.SocketsHttpHandler.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
 4namespace System.Net.Http
 5{
 6    internal static partial class HttpUtilities
 7    {
 8        internal static bool IsSupportedScheme(string scheme) =>
 09            IsSupportedNonSecureScheme(scheme) ||
 010            IsSupportedSecureScheme(scheme);
 11
 12        internal static bool IsSupportedNonSecureScheme(string scheme) =>
 013            string.Equals(scheme, "http", StringComparison.OrdinalIgnoreCase) || IsNonSecureWebSocketScheme(scheme);
 14
 15        internal static bool IsSupportedSecureScheme(string scheme) =>
 016            string.Equals(scheme, "https", StringComparison.OrdinalIgnoreCase) || IsSecureWebSocketScheme(scheme);
 17
 18        internal static bool IsNonSecureWebSocketScheme(string scheme) =>
 019            string.Equals(scheme, "ws", StringComparison.OrdinalIgnoreCase);
 20
 21        internal static bool IsSecureWebSocketScheme(string scheme) =>
 022            string.Equals(scheme, "wss", StringComparison.OrdinalIgnoreCase);
 23
 24        internal static bool IsSupportedProxyScheme(string scheme) =>
 025            string.Equals(scheme, "http", StringComparison.OrdinalIgnoreCase) || string.Equals(scheme, "https", StringCo
 26
 27        internal static bool IsSocksScheme(string scheme) =>
 028            string.Equals(scheme, "socks5", StringComparison.OrdinalIgnoreCase) ||
 029            string.Equals(scheme, "socks4a", StringComparison.OrdinalIgnoreCase) ||
 030            string.Equals(scheme, "socks4", StringComparison.OrdinalIgnoreCase);
 31    }
 32}