Ejemplo n.º 1
0
 public static void ConnectionAborted(ILogger logger, BaseConnectionContext connection, long errorCode, Exception ex)
 {
     if (logger.IsEnabled(LogLevel.Debug))
     {
         ConnectionAbortedCore(logger, connection.ConnectionId, errorCode, ex);
     }
 }
Ejemplo n.º 2
0
        public Http2FrameWriter(
            PipeWriter outputPipeWriter,
            BaseConnectionContext connectionContext,
            Http2Connection http2Connection,
            OutputFlowControl connectionOutputFlowControl,
            ITimeoutControl timeoutControl,
            MinDataRate?minResponseDataRate,
            string connectionId,
            MemoryPool <byte> memoryPool,
            ServiceContext serviceContext)
        {
            // Allow appending more data to the PipeWriter when a flush is pending.
            _outputWriter                = new ConcurrentPipeWriter(outputPipeWriter, memoryPool, _writeLock);
            _connectionContext           = connectionContext;
            _http2Connection             = http2Connection;
            _connectionOutputFlowControl = connectionOutputFlowControl;
            _connectionId                = connectionId;
            _log                 = serviceContext.Log;
            _timeoutControl      = timeoutControl;
            _minResponseDataRate = minResponseDataRate;
            _flusher             = new TimingPipeFlusher(timeoutControl, serviceContext.Log);
            _flusher.Initialize(_outputWriter);
            _outgoingFrame        = new Http2Frame();
            _headerEncodingBuffer = new byte[_maxFrameSize];

            _scheduleInline = serviceContext.Scheduler == PipeScheduler.Inline;

            _hpackEncoder = new DynamicHPackEncoder(serviceContext.ServerOptions.AllowResponseHeaderCompression);
        }
 public void ConnectionStop(BaseConnectionContext connection)
 {
     if (IsEnabled())
     {
         ConnectionStop(connection.ConnectionId);
     }
 }
Ejemplo n.º 4
0
 public void ConnectionError(BaseConnectionContext connection, Exception ex)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _connectionError(_logger, connection.ConnectionId, ex);
     }
 }
Ejemplo n.º 5
0
 public static void ConnectionAbort(ILogger logger, BaseConnectionContext connection, long errorCode, string reason)
 {
     if (logger.IsEnabled(LogLevel.Debug))
     {
         ConnectionAbortCore(logger, connection.ConnectionId, errorCode, reason);
     }
 }
Ejemplo n.º 6
0
 public void AcceptedConnection(BaseConnectionContext connection)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         _acceptedConnection(_logger, connection.ConnectionId, null);
     }
 }
Ejemplo n.º 7
0
        public static Http3StreamContext CreateHttp3StreamContext(
            string connectionId = null,
            BaseConnectionContext connectionContext = null,
            ServiceContext serviceContext           = null,
            IFeatureCollection connectionFeatures   = null,
            MemoryPool <byte> memoryPool            = null,
            IPEndPoint localEndPoint       = null,
            IPEndPoint remoteEndPoint      = null,
            IDuplexPipe transport          = null,
            ITimeoutControl timeoutControl = null,
            IHttp3StreamLifetimeHandler streamLifetimeHandler = null)
        {
            var context = new Http3StreamContext
                          (
                connectionId: connectionId ?? "TestConnectionId",
                protocols: HttpProtocols.Http3,
                altSvcHeader: null,
                connectionContext: connectionContext,
                serviceContext: serviceContext ?? CreateServiceContext(new KestrelServerOptions()),
                connectionFeatures: connectionFeatures ?? new FeatureCollection(),
                memoryPool: memoryPool ?? MemoryPool <byte> .Shared,
                localEndPoint: localEndPoint,
                remoteEndPoint: remoteEndPoint,
                streamLifetimeHandler: streamLifetimeHandler,
                streamContext: new DefaultConnectionContext(),
                clientPeerSettings: new Http3PeerSettings(),
                serverPeerSettings: null
                          );

            context.TimeoutControl = timeoutControl;
            context.Transport      = transport;

            return(context);
        }
Ejemplo n.º 8
0
 public static void AcceptedConnection(ILogger logger, BaseConnectionContext connection)
 {
     if (logger.IsEnabled(LogLevel.Debug))
     {
         AcceptedConnectionCore(logger, connection.ConnectionId);
     }
 }
Ejemplo n.º 9
0
 public void ConnectionAbort(BaseConnectionContext connection, string reason)
 {
     if (_logger.IsEnabled(LogLevel.Debug))
     {
         ConnectionAbort(_logger, connection.ConnectionId, reason);
     }
 }
Ejemplo n.º 10
0
 public void ConnectionStop(BaseConnectionContext connection)
 {
     Interlocked.Decrement(ref _currentConnections);
     if (IsEnabled())
     {
         ConnectionStop(connection.ConnectionId);
     }
 }
Ejemplo n.º 11
0
 public void TlsHandshakeStart(BaseConnectionContext connectionContext, SslServerAuthenticationOptions sslOptions)
 {
     Interlocked.Increment(ref _currentTlsHandshakes);
     Interlocked.Increment(ref _totalTlsHandshakes);
     if (IsEnabled())
     {
         TlsHandshakeStart(connectionContext.ConnectionId, sslOptions.EnabledSslProtocols.ToString());
     }
 }
Ejemplo n.º 12
0
        public void ConnectionStop(BaseConnectionContext connection)
        {
            Interlocked.Decrement(ref _currentConnections);

            if (IsEnabled(EventLevel.Informational, EventKeywords.None))
            {
                ConnectionStop(connection.ConnectionId);
            }
        }
Ejemplo n.º 13
0
 public void ConnectionQueuedStop(BaseConnectionContext connection)
 {
     Interlocked.Decrement(ref _connectionQueueLength);
     if (IsEnabled())
     {
         ConnectionQueuedStop(
             connection.ConnectionId,
             connection.LocalEndPoint?.ToString(),
             connection.RemoteEndPoint?.ToString());
     }
 }
 public void ConnectionStart(BaseConnectionContext connection)
 {
     // avoid allocating strings unless this event source is enabled
     if (IsEnabled())
     {
         ConnectionStart(
             connection.ConnectionId,
             connection.LocalEndPoint?.ToString(),
             connection.RemoteEndPoint?.ToString());
     }
 }
Ejemplo n.º 15
0
 public HttpConnectionContext(
     string connectionId,
     HttpProtocols protocols,
     AltSvcHeader?altSvcHeader,
     BaseConnectionContext connectionContext,
     ServiceContext serviceContext,
     IFeatureCollection connectionFeatures,
     MemoryPool <byte> memoryPool,
     IPEndPoint?localEndPoint,
     IPEndPoint?remoteEndPoint) : base(connectionId, protocols, altSvcHeader, connectionContext, serviceContext, connectionFeatures, memoryPool, localEndPoint, remoteEndPoint)
 {
 }
Ejemplo n.º 16
0
 public void TlsHandshakeStop(BaseConnectionContext connectionContext, TlsConnectionFeature?feature)
 {
     Interlocked.Decrement(ref _currentTlsHandshakes);
     if (IsEnabled())
     {
         // TODO: Write this without a string allocation using WriteEventData
         var applicationProtocol = feature == null ? string.Empty : Encoding.UTF8.GetString(feature.ApplicationProtocol.Span);
         var sslProtocols        = feature?.Protocol.ToString() ?? string.Empty;
         var hostName            = feature?.HostName ?? string.Empty;
         TlsHandshakeStop(connectionContext.ConnectionId, sslProtocols, applicationProtocol, hostName);
     }
 }
Ejemplo n.º 17
0
        public void ConnectionStart(BaseConnectionContext connection)
        {
            // avoid allocating strings unless this event source is enabled
            Interlocked.Increment(ref _totalConnections);
            Interlocked.Increment(ref _currentConnections);

            if (IsEnabled())
            {
                ConnectionStart(
                    connection.ConnectionId,
                    connection.LocalEndPoint?.ToString(),
                    connection.RemoteEndPoint?.ToString());
            }
        }
Ejemplo n.º 18
0
    public static Http3StreamContext CreateHttp3StreamContext(
        string connectionId = null,
        BaseConnectionContext connectionContext = null,
        ServiceContext serviceContext           = null,
        IFeatureCollection connectionFeatures   = null,
        MemoryPool <byte> memoryPool            = null,
        IPEndPoint localEndPoint       = null,
        IPEndPoint remoteEndPoint      = null,
        IDuplexPipe transport          = null,
        ITimeoutControl timeoutControl = null,
        IHttp3StreamLifetimeHandler streamLifetimeHandler = null)
    {
        var http3ConnectionContext = CreateHttp3ConnectionContext(
            null,
            serviceContext,
            connectionFeatures,
            memoryPool,
            localEndPoint,
            remoteEndPoint,
            timeoutControl);

        var http3Conection = new Http3Connection(http3ConnectionContext)
        {
            _streamLifetimeHandler = streamLifetimeHandler
        };

        return(new Http3StreamContext
               (
                   connectionId: connectionId ?? "TestConnectionId",
                   protocols: HttpProtocols.Http3,
                   altSvcHeader: null,
                   connectionContext: connectionContext,
                   serviceContext: serviceContext ?? CreateServiceContext(new KestrelServerOptions()),
                   connectionFeatures: connectionFeatures ?? new FeatureCollection(),
                   memoryPool: memoryPool ?? MemoryPool <byte> .Shared,
                   localEndPoint: localEndPoint,
                   remoteEndPoint: remoteEndPoint,
                   streamContext: new DefaultConnectionContext(),
                   connection: http3Conection
               )
        {
            TimeoutControl = timeoutControl,
            Transport = transport,
        });
    }
Ejemplo n.º 19
0
 public Http3StreamContext(
     string connectionId,
     HttpProtocols protocols,
     AltSvcHeader?altSvcHeader,
     BaseConnectionContext connectionContext,
     ServiceContext serviceContext,
     IFeatureCollection connectionFeatures,
     MemoryPool <byte> memoryPool,
     IPEndPoint?localEndPoint,
     IPEndPoint?remoteEndPoint,
     ConnectionContext streamContext,
     Http3Connection connection) : base(connectionId, protocols, altSvcHeader, connectionContext, serviceContext, connectionFeatures, memoryPool, localEndPoint, remoteEndPoint)
 {
     StreamLifetimeHandler = connection._streamLifetimeHandler;
     StreamContext         = streamContext;
     ClientPeerSettings    = connection._clientSettings;
     ServerPeerSettings    = connection._serverSettings;
     Connection            = connection;
 }
Ejemplo n.º 20
0
 public BaseHttpConnectionContext(
     string connectionId,
     HttpProtocols protocols,
     BaseConnectionContext connectionContext,
     ServiceContext serviceContext,
     IFeatureCollection connectionFeatures,
     MemoryPool <byte> memoryPool,
     IPEndPoint?localEndPoint,
     IPEndPoint?remoteEndPoint)
 {
     ConnectionId       = connectionId;
     Protocols          = protocols;
     ConnectionContext  = connectionContext;
     ServiceContext     = serviceContext;
     ConnectionFeatures = connectionFeatures;
     MemoryPool         = memoryPool;
     LocalEndPoint      = localEndPoint;
     RemoteEndPoint     = remoteEndPoint;
 }
Ejemplo n.º 21
0
        public Http1OutputProducer(
            PipeWriter pipeWriter,
            string connectionId,
            BaseConnectionContext connectionContext,
            MemoryPool <byte> memoryPool,
            IKestrelTrace log,
            ITimeoutControl timeoutControl,
            IHttpMinResponseDataRateFeature minResponseDataRateFeature,
            IHttpOutputAborter outputAborter)
        {
            // Allow appending more data to the PipeWriter when a flush is pending.
            _pipeWriter        = new ConcurrentPipeWriter(pipeWriter, memoryPool, _contextLock);
            _connectionId      = connectionId;
            _connectionContext = connectionContext;
            _memoryPool        = memoryPool;
            _log = log;
            _minResponseDataRateFeature = minResponseDataRateFeature;
            _outputAborter = outputAborter;

            _flusher = new TimingPipeFlusher(_pipeWriter, timeoutControl, log);
        }
Ejemplo n.º 22
0
 public void ConnectionQueuedStop(BaseConnectionContext connection)
 {
     Interlocked.Decrement(ref _connectionQueueLength);
 }
Ejemplo n.º 23
0
 public ConnectionContextAdapter(BaseConnectionContext inner) => _inner = inner;