< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 55
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpConnectionContext.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.CodeAnalysis;
 5using System.Diagnostics.Tracing;
 6
 7namespace System.Net.Http
 8{
 9    /// <summary>
 10    /// Represents the context passed to the ConnectCallback for a SocketsHttpHandler instance.
 11    /// </summary>
 12    public sealed class SocketsHttpConnectionContext
 13    {
 14        private readonly DnsEndPoint _dnsEndPoint;
 15        private readonly HttpRequestMessage _initialRequestMessage;
 16        private readonly long _connectionId;
 17
 018        internal SocketsHttpConnectionContext(DnsEndPoint dnsEndPoint, HttpRequestMessage initialRequestMessage, long co
 019        {
 020            _dnsEndPoint = dnsEndPoint;
 021            _initialRequestMessage = initialRequestMessage;
 022            _connectionId = connectionId;
 023        }
 24
 25        /// <summary>
 26        /// The DnsEndPoint to be used by the ConnectCallback to establish the connection.
 27        /// </summary>
 028        public DnsEndPoint DnsEndPoint => _dnsEndPoint;
 29
 30        /// <summary>
 31        /// The initial HttpRequestMessage that is causing the connection to be created.
 32        /// </summary>
 033        public HttpRequestMessage InitialRequestMessage => _initialRequestMessage;
 34
 35        /// <summary>
 36        /// The identifier that will be assigned to the connection being established. This matches the connection id
 37        /// reported through <see cref="EventSource"/> telemetry, the
 38        /// <see cref="SocketsHttpConnectionEvictionContext.ConnectionId"/> passed to
 39        /// <see cref="SocketsHttpHandler.ShouldEvictConnection"/>, and the
 40        /// <see cref="HttpRequestMessage.ConnectionId"/> stamped on requests sent over the connection. It can be used
 41        /// to associate caller state (for example, the resolved address used) with the connection and to correlate it
 42        /// with the requests it serves, so that state can be recovered later (for example when deciding on eviction).
 43        /// </summary>
 44        /// <remarks>
 45        /// When establishing the transport for an HTTP CONNECT proxy tunnel, this id identifies that transport
 46        /// connection to the proxy; the tunneled connection layered over it serves the requests and carries a distinct
 47        /// id, which is the one reported to <see cref="SocketsHttpHandler.ShouldEvictConnection"/> and stamped on those
 48        /// requests. A <see cref="SocketsHttpHandler.PlaintextStreamFilter"/> runs on each hop and surfaces both: this
 49        /// (transport) id on the CONNECT hop and the tunneled connection's id on the subsequent hop.
 50        /// </remarks>
 51        [Experimental(Experimentals.SocketsHttpHandlerExperimentalDiagId, UrlFormat = Experimentals.SharedUrlFormat)]
 052        public long ConnectionId => _connectionId;
 53    }
 54}
 55