Esempio n. 1
0
        private void Accept(NameValueHeaderBlock?headers =
                            default)
        {
            if (_synStream.IsUnidirectional)
            {
                CloseRemote();
            }
            else
            {
                OpenRemote();
            }

            var reply = SynReply.Accept(Id, headers);

            if (_synStream.IsFin || reply.IsLastFrame)
            {
                CloseLocal();
            }
            else
            {
                OpenLocal();
            }

            _controlFramesReceived.TryAdd(typeof(SynReply), reply);
            Send(reply);
        }
Esempio n. 2
0
            protected override async Task GivenASessionAsync(
                CancellationToken cancellationToken)
            {
                var synStreamSubscription = Server.On <SynStream>();

                Server.On <GoAway>();
                _stream = Session.Open();
                await synStreamSubscription.ReceiveAsync(cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    SynReply.Accept(_stream.Id), cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    new Settings(Settings.InitialWindowSize(5)),
                    cancellationToken)
                .ConfigureAwait(false);

                // Need to send something after settings in order to know when settings have been set
                Server.On <WindowUpdate>();
                await Server.SendAsync(
                    new Data(
                        _stream.Id,
                        Encoding.UTF8.GetBytes("dummy")),
                    cancellationToken)
                .ConfigureAwait(false);

                await _stream.ReceiveAsync(cancellationToken : cancellationToken)
                .ConfigureAwait(false);
            }
Esempio n. 3
0
            protected override async Task GivenASessionAsync(
                CancellationToken cancellationToken)
            {
                Server.On <GoAway>();
                var synStreamSubscription = Server.On <SynStream>(cancellationToken);

                _pingSubscription = Server.On <Ping>(cancellationToken);
                _stream           = DisposeOnTearDown(
                    Session.Open(options: SynStream.Options.Fin));
                await synStreamSubscription.ReceiveAsync(cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    SynReply.Accept(
                        _stream.Id,
                        new NameValueHeaderBlock(
                            ("header1", new[] { "Value1" })
                            )),
                    cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    new Ping(0),
                    cancellationToken)
                .ConfigureAwait(false);
            }
Esempio n. 4
0
            protected override async Task WhenAsync(
                CancellationToken cancellationToken)
            {
                await Server.SendAsync(
                    SynReply.Accept(_stream.Id),
                    cancellationToken)
                .ConfigureAwait(false);

                _rstStream = await _rstStreamSubscription
                             .ReceiveAsync(CancellationToken)
                             .ConfigureAwait(false);
            }
Esempio n. 5
0
            protected override async Task GivenASessionAsync(
                CancellationToken cancellationToken)
            {
                var synStreamSubscription = Server.On <SynStream>();

                Server.On <GoAway>();
                _stream = DisposeOnTearDown(
                    Session.Open(options: SynStream.Options.Unidirectional | SynStream.Options.Fin));
                await synStreamSubscription.ReceiveAsync(cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    SynReply.Accept(_stream.Id), cancellationToken)
                .ConfigureAwait(false);
            }
Esempio n. 6
0
            protected override async Task GivenASessionAsync(
                CancellationToken cancellationToken)
            {
                var synStreamSubscription = Server.On <SynStream>(cancellationToken);

                Server.On <GoAway>(cancellationToken);
                _windowUpdateSubscription = Server.On <WindowUpdate>(cancellationToken);
                _stream = Session.Open();
                await synStreamSubscription.ReceiveAsync(cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    SynReply.Accept(
                        _stream.Id),
                    cancellationToken)
                .ConfigureAwait(false);

                await Server.SendAsync(
                    Data.Last(
                        _stream.Id,
                        Encoding.UTF8.GetBytes("my data")),
                    cancellationToken)
                .ConfigureAwait(false);
            }