//Outgoing internal Http2Stream(int id, WriteQueue writeQueue, FlowControlManager flowCrtlManager, int priority = Constants.DefaultStreamPriority) { if (id <= 0) throw new ArgumentOutOfRangeException("invalid id for stream"); if (priority < 0 || priority > Constants.MaxPriority) throw new ArgumentOutOfRangeException("priority out of range"); _id = id; Priority = priority; _writeQueue = writeQueue; _flowCrtlManager = flowCrtlManager; _unshippedFrames = new Queue<DataFrame>(16); Headers = new HeadersList(); SentDataAmount = 0; ReceivedDataAmount = 0; IsFlowControlBlocked = false; IsFlowControlEnabled = _flowCrtlManager.IsFlowControlEnabled; WindowSize = _flowCrtlManager.StreamsInitialWindowSize; _flowCrtlManager.NewStreamOpenedHandler(this); OnFrameSent += (sender, args) => FramesSent++; }
//Incoming internal Http2Stream(HeadersList headers, int id, WriteQueue writeQueue, FlowControlManager flowCrtlManager, ICompressionProcessor comprProc, int priority = Constants.DefaultStreamPriority) : this(id, writeQueue, flowCrtlManager, comprProc, priority) { if (headers == null) throw new ArgumentNullException("cannot create stream with null headers"); Headers = headers; }
//Incoming internal Http2Stream(HeadersList headers, int id, WriteQueue writeQueue, FlowControlManager flowCrtlManager, int priority = Constants.DefaultStreamPriority) : this(id, writeQueue, flowCrtlManager, priority) { Headers = headers; }
public Http2Session(Stream stream, ConnectionEnd end, bool usePriorities, bool useFlowControl, bool isSecure, CancellationToken cancel, int initialWindowSize = Constants.InitialFlowControlWindowSize, int maxConcurrentStreams = Constants.DefaultMaxConcurrentStreams) { if (stream == null) throw new ArgumentNullException("stream is null"); if (cancel == null) throw new ArgumentNullException("cancellation token is null"); if (maxConcurrentStreams <= 0) throw new ArgumentOutOfRangeException("maxConcurrentStreams cant be less or equal then 0"); if (initialWindowSize <= 0 && useFlowControl) throw new ArgumentOutOfRangeException("initialWindowSize cant be less or equal then 0"); _ourEnd = end; _usePriorities = usePriorities; _useFlowControl = useFlowControl; _isSecure = isSecure; _cancelSessionToken = cancel; if (_ourEnd == ConnectionEnd.Client) { _remoteEnd = ConnectionEnd.Server; _lastId = -1; // Streams opened by client are odd //if we got unsecure connection then server will respond with id == 1. We cant initiate //new stream with id == 1. if (!(stream is SslStream)) { _lastId = 3; } } else { _remoteEnd = ConnectionEnd.Client; _lastId = 0; // Streams opened by server are even } _goAwayReceived = false; _comprProc = new CompressionProcessor(_ourEnd); _ioStream = stream; _frameReader = new FrameReader(_ioStream); ActiveStreams = new ActiveStreams(); _writeQueue = new WriteQueue(_ioStream, ActiveStreams, _comprProc, _usePriorities); OurMaxConcurrentStreams = maxConcurrentStreams; RemoteMaxConcurrentStreams = maxConcurrentStreams; InitialWindowSize = initialWindowSize; _flowControlManager = new FlowControlManager(this); if (!_useFlowControl) { _flowControlManager.Options = (byte) FlowControlOptions.DontUseFlowControl; } SessionWindowSize = 0; _headersSequences = new HeadersSequenceList(); _promisedResources = new Dictionary<int, string>(); }