public FlowControlledData(DefaultHttp2ConnectionEncoder encoder,
                           IHttp2Stream stream, IByteBuffer buf, int padding, bool endOfStream, IPromise promise, IChannel channel)
     : base(encoder, stream, padding, endOfStream, promise)
 {
     _queue = new CoalescingBufferQueue(channel);
     _queue.Add(buf, promise);
     _dataSize = _queue.ReadableBytes();
 }
 public FlowControlledBase(DefaultHttp2ConnectionEncoder encoder, IHttp2Stream stream, int padding, bool endOfStream, IPromise promise)
 {
     if ((uint)padding > SharedConstants.TooBigOrNegative)
     {
         ThrowHelper.ThrowArgumentException_PositiveOrZero(ExceptionArgument.padding);
     }
     _owner       = encoder;
     _padding     = padding;
     _endOfStream = endOfStream;
     _stream      = stream;
     _promise     = promise;
 }
 public FlowControlledHeaders(DefaultHttp2ConnectionEncoder encoder,
                              IHttp2Stream stream, IHttp2Headers headers, bool hasPriority,
                              int streamDependency, short weight, bool exclusive,
                              int padding, bool endOfStream, IPromise promise)
     : base(encoder, stream, padding, endOfStream, promise.Unvoid())
 {
     _headers          = headers;
     _hasPriority      = hasPriority;
     _streamDependency = streamDependency;
     _weight           = weight;
     _exclusive        = exclusive;
 }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public override Http2MultiplexCodec Build()
        {
            var frameWriter = _frameWriter;

            if (frameWriter is object)
            {
                // This is to support our tests and will never be executed by the user as frameWriter(...)
                // is package-private.
                var connection                = new DefaultHttp2Connection(IsServer, MaxReservedStreams);
                var maxHeaderListSize         = InitialSettings.MaxHeaderListSize();
                IHttp2FrameReader frameReader = new DefaultHttp2FrameReader(!maxHeaderListSize.HasValue ?
                                                                            new DefaultHttp2HeadersDecoder(IsValidateHeaders) :
                                                                            new DefaultHttp2HeadersDecoder(IsValidateHeaders, maxHeaderListSize.Value));

                var frameLogger = FrameLogger;
                if (frameLogger is object)
                {
                    frameWriter = new Http2OutboundFrameLogger(frameWriter, frameLogger);
                    frameReader = new Http2InboundFrameLogger(frameReader, frameLogger);
                }
                IHttp2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(connection, frameWriter);
                if (EncoderEnforceMaxConcurrentStreams)
                {
                    encoder = new StreamBufferingEncoder(encoder);
                }
                IHttp2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(connection, encoder, frameReader,
                                                                                    PromisedRequestVerifier, AutoAckSettingsFrame, AutoAckPingFrame);

                int maxConsecutiveEmptyDataFrames = DecoderEnforceMaxConsecutiveEmptyDataFrames;
                if ((uint)maxConsecutiveEmptyDataFrames > 0u)
                {
                    decoder = new Http2EmptyDataFrameConnectionDecoder(decoder, maxConsecutiveEmptyDataFrames);
                }

                return(Build(decoder, encoder, InitialSettings));
            }
            return(base.Build());
        }