Exemplo n.º 1
0
        public async Task SSETurnsResponseBufferingOff()
        {
            var channel = Channel.CreateUnbounded <byte[]>();
            var context = new DefaultHttpContext();
            var feature = new HttpBufferingFeature();

            context.Features.Set <IHttpBufferingFeature>(feature);
            var sse = new ServerSentEventsTransport(channel, connectionId: string.Empty, loggerFactory: new LoggerFactory());

            Assert.True(channel.Writer.TryComplete());

            await sse.ProcessRequestAsync(context, context.RequestAborted);

            Assert.True(feature.ResponseBufferingDisabled);
        }
Exemplo n.º 2
0
        public async Task SSETurnsResponseBufferingOff()
        {
            var pair       = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
            var connection = new DefaultConnectionContext("foo", pair.Transport, pair.Application);
            var context    = new DefaultHttpContext();

            var feature = new HttpBufferingFeature();

            context.Features.Set <IHttpBufferingFeature>(feature);
            var sse = new ServerSentEventsTransport(connection.Application.Input, connectionId: connection.ConnectionId, loggerFactory: new LoggerFactory());

            connection.Transport.Output.Complete();

            await sse.ProcessRequestAsync(context, context.RequestAborted);

            Assert.True(feature.ResponseBufferingDisabled);
        }