Exemplo n.º 1
0
            public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
            {
                _connection = connection;
                _streamId   = streamId;

                _request         = request;
                _responseContent = new HttpConnectionResponseContent();
                _response        = new HttpResponseMessage()
                {
                    Version = HttpVersion.Version20, RequestMessage = request, Content = _responseContent
                };

                _syncObject = new object();
                _disposed   = false;

                _responseBuffer = new ArrayBuffer(InitialBufferSize);

                _streamWindow = new CreditManager(initialWindowSize);

                _responseHeadersAvailable = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously);

                // TODO: ISSUE 31313: Avoid allocating a TaskCompletionSource repeatedly by using a resettable ValueTaskSource.
                // See: https://github.com/dotnet/corefx/blob/master/src/Common/tests/System/Threading/Tasks/Sources/ManualResetValueTaskSource.cs
                _responseDataAvailable = null;
            }
Exemplo n.º 2
0
            public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
            {
                _connection = connection;
                _streamId   = streamId;

                _state = StreamState.ExpectingStatus;

                _request = request;
                _shouldSendRequestBody = true;

                _disposed = false;

                _responseBuffer = new ArrayBuffer(InitialStreamBufferSize, usePool: true);

                _pendingWindowUpdate = 0;

                _streamWindow = new CreditManager(this, nameof(_streamWindow), initialWindowSize);

                _headerBudgetRemaining = connection._pool.Settings._maxResponseHeadersLength * 1024;

                if (NetEventSource.IsEnabled)
                {
                    Trace($"{request}, {nameof(initialWindowSize)}={initialWindowSize}");
                }
            }
Exemplo n.º 3
0
            public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
            {
                _connection = connection;
                _streamId   = streamId;

                _state = StreamState.ExpectingHeaders;

                _request  = request;
                _response = new HttpResponseMessage()
                {
                    Version        = HttpVersion.Version20,
                    RequestMessage = request,
                    Content        = new HttpConnectionResponseContent()
                };

                _disposed = false;

                _responseBuffer = new ArrayBuffer(InitialStreamBufferSize, usePool: true);

                _pendingWindowUpdate = 0;

                _streamWindow = new CreditManager(initialWindowSize);

                // TODO: ISSUE 31313: Avoid allocating a TaskCompletionSource repeatedly by using a resettable ValueTaskSource.
                // See: https://github.com/dotnet/corefx/blob/master/src/Common/tests/System/Threading/Tasks/Sources/ManualResetValueTaskSource.cs
                _waiterTaskSource = null;
            }
Exemplo n.º 4
0
            public Http2Stream(Http2Connection connection)
            {
                _connection = connection;

                _streamId = connection.AddStream(this);

                _syncObject = new object();
                _disposed   = false;

                _responseBuffer = new ArrayBuffer(InitialBufferSize);

                _streamWindow = new CreditManager(InitialWindowSize);
            }
Exemplo n.º 5
0
            public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
            {
                _connection = connection;
                _streamId   = streamId;

                _state = StreamState.ExpectingHeaders;

                _request = request;

                _disposed = false;

                _responseBuffer = new ArrayBuffer(InitialStreamBufferSize, usePool: true);

                _pendingWindowUpdate = 0;

                _streamWindow = new CreditManager(initialWindowSize);
            }
Exemplo n.º 6
0
        public Http2Connection(HttpConnectionPool pool, SslStream stream)
        {
            _pool           = pool;
            _stream         = stream;
            _syncObject     = new object();
            _incomingBuffer = new ArrayBuffer(InitialBufferSize);
            _outgoingBuffer = new ArrayBuffer(InitialBufferSize);
            _headerBuffer   = new ArrayBuffer(InitialBufferSize);

            _hpackDecoder = new HPackDecoder();

            _httpStreams = new Dictionary <int, Http2Stream>();

            _writerLock       = new SemaphoreSlim(1, 1);
            _connectionWindow = new CreditManager(InitialWindowSize);

            _nextStream = 1;
        }
Exemplo n.º 7
0
            public Http2Stream(HttpRequestMessage request, Http2Connection connection, int streamId, int initialWindowSize)
            {
                _connection = connection;
                _streamId   = streamId;

                _state = StreamState.ExpectingStatus;

                _request = request;
                _shouldSendRequestBody = true;

                _disposed = false;

                _responseBuffer = new ArrayBuffer(InitialStreamBufferSize, usePool: true);

                _pendingWindowUpdate = 0;

                _streamWindow = new CreditManager(initialWindowSize);

                _headerBudgetRemaining = connection._pool.Settings._maxResponseHeadersLength * 1024;
            }